I am having a multiselect dropdown as below
<select id="data" name="data" class="data" multiple="multiple">
<option value="100">foo</option>
<option value="101">bar</option>
<option value="102">bat</option>
<option value="103">baz</option>
</select>
On load of page, i will get an array of value like [101,102]. I should iterate through the array and make the values selected(check boxes corresponding to the ids should be checked). Please help.
I ended up having to make a slight change using the click event on the input element by also setting the checked prop after firing the click event.
this is my code sample. I have comma separated numbers for multi select drop down and want to select options multiple options from comma separated values.
It's supposed to be as simple as this:
Check my Fiddle: https://jsfiddle.net/luthrayatin/jaLygLzo/
This is what worked from me using an array as input. First uncheck all options, then click on the chosen options using jquery
I hope these functions will help you.
$('#your-select').multiSelect('select', String|Array);
$('#your-select').multiSelect('deselect', String|Array);
$('#your-select').multiSelect('select_all');
$('#your-select').multiSelect('deselect_all');
$('#your-select').multiSelect('refresh');
Reference by this site Reference
You can try this: