/* * * MultiSelect jQuery plugin * * The external resources are: * jQuery 1.x + Jquery UI * * multiselect-min.js * the plugin to get the multiselection */ // Populates select tags with option tags var populateSelects = function(nOptions){ if(typeof nOptions != "number") nOptions = 25; var options_HTML = ""; for(var i = 0; i < nOptions; i++) options_HTML += ""; $("#test_target_no_optgroup").append(options_HTML); $("#test_target_with_optgroup_fc0").append(options_HTML); $("#test_target_with_optgroup_fc1").append(options_HTML); $("#test_target_with_optgroup_fc2").append(options_HTML); $("#test_target_with_optgroup_fc3").append(options_HTML); }; // Applies multiselection on select tags var test_Multiselection = function(){ $("#test_target_no_optgroup").MultiSelect({ size: 20, css_class_selected: "test-selection" }); }; // Applies feature to select / deselect all options inside optgroup, by one click var test_categoriesSelection = function(){ $("#test_target_with_optgroup").MultiSelect({ size: 30, css_class_selected: "test-selection", enableCategoriesSel: true }); } // Main $(document).ready(function(){ populateSelects(); test_Multiselection(); test_categoriesSelection(); $("#getV").click(function(){ alert( $("#test_target_no_optgroup").val() ); }); $("#getV2").click(function(){ alert( $("#test_target_with_optgroup").val() ); }); });