Multiple Select dropdown list using Jquery


In this post , we know how to implement multiple select drop down list in our project . Often we need in every project to select multiple value like as a multiple hobbies , multiple country , multiple specialty etc. There we implement multiple select drop down list using Jquery , Bootstrap .

In this article we need to one css file ( multi_select.min.css ) and three js file ( multi_select.min.js ) , ( jquery.min.js ) , ( custom.js ) . These file will include in our index.html file .

index.php


<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Select multiple Dropdown list using jQuery</title>

</head>

<link href="multi_select.min.css" type="text/css" rel="stylesheet" />

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<body>

  <div class="container" style="margin-top:100px;">

    <div class="row">

      <div class="col-sm-6">

          <label>Select Multiple Country</label>

          <select data-placeholder="Choose a Country..." class="chosen-select" multiple tabindex="4">

            <option value=""></option>

            <option value="United States">United States</option>

            <option value="United Kingdom">United Kingdom</option>

            <option value="Afghanistan">Afghanistan</option>

            <option value="Aland Islands">Aland Islands</option>

            <option value="Albania">Albania</option>

            <option value="Algeria">Algeria</option>

            <option value="American Samoa">American Samoa</option>

            <option value="Andorra">Andorra</option>

            <option value="Angola">Angola</option>

            <option value="Anguilla">Anguilla</option>

            <option value="Antarctica">Antarctica</option>

            <option value="Antigua and Barbuda">Antigua and Barbuda</option>

            <option value="Argentina">Argentina</option>

            <option value="Armenia">Armenia</option>

            <option value="Aruba">Aruba</option>

            <option value="Australia">Australia</option>

            <option value="Austria">Austria</option>

            <option value="Azerbaijan">Azerbaijan</option>

            <option value="Bahamas">Bahamas</option>

            <option value="Bahrain">Bahrain</option>

            <option value="Bangladesh">Bangladesh</option>

            <option value="Barbados">Barbados</option>

            <option value="Belarus">Belarus</option>

            <option value="Belgium">Belgium</option>

            <option value="Belize">Belize</option>

          </select>

        </div>    

      <div class="col-sm-6"></div>  

    </div>  

      

  </div>    

<script src="jquery.min.js"></script> 

<script src="multi_select.min.js"></script>     

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>

</html>

     

    
 
 

custom.js


var config = {

  '.chosen-select'           : {},

  '.chosen-select-deselect'  : { allow_single_deselect: true },

  '.chosen-select-no-single' : { disable_search_threshold: 10 },

  '.chosen-select-no-results': { no_results_text: 'Oops, nothing found!' },

  '.chosen-select-rtl'       : { rtl: true },

  '.chosen-select-width'     : { width: '95%' }

}

for (var selector in config) {

  $(selector).chosen(config[selector]);

}