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.
Thank you all for your answers.
Taking all of your answers as a guideline, I resolved the problem with the below code:
Thanks once again for all your support.
Here is a demo
This selects the options whose value matches with values in array.
work fine for me ,change ids according to you requirement.