multiselect – a jQueryUI form widget
Welcome to the multiselect project page! multiselect is a jQuery UI plugin that transforms a form select combobox into a dropdown menu, that utilizes YOUR jQueryUI theme!
Requirements
To use multiselect, it is recommended that you use jQuery version 1.6+. Reference the jQuery library followed the multiselect JavaScript file:
<!-- load jQuery library --> <script src="/common/js/libs/jquery-1.6.min.js"></script> <!-- load multiselect plugin --> <script src="jquery.ui.multiselect.js"></script>
Now you are ready to use multiselect! Below is some example code on the ways you can use it.
Simple Multiselect
The easiest way to create the multiselect widget is to just call it on a <select> element.
<!-- transform a select box -->
<script>
$('select').multiselect();
</script>
Multiselect w/ Options
- label: sets the label for the dropdown widget (default is ‘– Select Option –’)
- minWidth: sets the minimum width of the dropdown widget (default is 200)
- maxWidth: sets the maximum width of the dropwdown before wrapping (no default set)
- scroll: sets the height of the dropdown options before scrolling (default is 0, no scrolling)
<!-- set your options -->
<script>
$('select').multiselect({
label: 'Select Your Options', // default is '-- Select Option --'
minWidth: 300, // default is 200
maxWidth: 300, // no default max width
scroll: 400
});
</script>
Initial Select (Pre-select)
If you want to have items initially selected by default, all you have to do is call the ‘select’ option of the plugin and pass it the index of the option you want to select.
$('select').multiselect('select', 0); // selects the first option
$('select').multiselect('select', 1); // selects the second option
// etc

{ 7 comments… read them below or add one }
Hey,
the script looks really nice but do you know a way to enable a pre-selection support?
so that selected=”selected” is included the script preselects the values and puts them into the list?
regards
Ah, nice question. I’ve added this to the documentation above. Hope this helps!
Very, very nice plugin!
Nice plugin, but I’ve got a question:
What method do I have to use to use onchange with multiselect? I’ve tried onchange, onblur, and onclick on the parent . I thought of using onblur for the dropdown created by multiselect, but I don’t want it firing without a selection. I know it can be worked-around with a global variable or something, but I’d like to avoid that.
Never mind, I think I figured it out. I tried binding click on .ui-menu-item, and that seems to work.
I found that , it will auto submit if you select any option when we put this plugin in a form. Can help me?
Here is my part codes:
Foo
Bar
Foo Bar
@leo-
nice catch. this has been fixed. you can download the latest file on GitHub. Thanks.
You can find more information here:
https://github.com/corydorning/multiselect/commit/cd737a0fe25b91f53374019688488c6d6b7c9e2d