davidstutz / bootstrap-multiselect

JQuery multiselect plugin based on Twitter Bootstrap.
https://davidstutz.github.io/bootstrap-multiselect/
Other
3.67k stars 1.98k forks source link

Dynamically set optgroup so all children of that group selected on page Load #1062

Open Ronak1010 opened 6 years ago

Ronak1010 commented 6 years ago

jQuery Code:

 $(document).ready(function () {
    var vCourses = '101,1005';   // string 101 = group-1 and 1005 = option of group-2 in HTML Below
   ...
   ...
});

HTML Code:

<select id="ddlCourses" name="ddlCourses" multiple="multiple" class="multiselect" >
    <optgroup class="group-1" value="101" label="(Reg)Basic&Ms-Office">
        <option value="1001">(Reg)Ms-Word</option>
        <option value="1002">(Reg)Ms-Excel</option>
        <option value="1003">(Reg)Ms-PowerPoint</option>
        <option value="1004">(Reg)Ms-Access</option>
    </optgroup>
    <optgroup class="group-2" value="102" label="ExcelCareer">
        <option value="1005">(Adv)Ms-Excel</option>
        <option value="1006">(VBA Macros)Ms-Excel</option>
    </optgroup>
</select>

Question: How to set all options of group-1 (value 101) and option (value 1005) selected... at page load event..? Thank you.

AngeloIapichino commented 5 years ago

Have you found a solution?