Set multiple select value in bootstrap selectpicker

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/css/bootstrap-select.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/js/bootstrap-select.min.js"></script>
 <select id="myselect" name="myselect[]" multiple>
   <option value=""></option>
   <option value="1">red</option>
   <option value="2">orange</option>
   <option value="3">green</option>
   <option value="4">blue</option>
 </select>
$(window).on('load', function() {
   $('#myselect').selectpicker();
   $('#myselect').selectpicker('val', [1, 3, 4]);
   $('#myselect').selectpicker('refresh');
})

I am using above code but still I get Nothing selected.

How do I set multiple values selected in bootstrap selectpicker.

I have tried solution given in below link:

How to set selected value on select using selectpicker plugin from bootstrap

6 thoughts on “Set multiple select value in bootstrap selectpicker”

Leave a Comment