jQuery MultiSelect
Written by Cory S.N. LaViska on April 6th, 2008
Improve multi-select form controls with this easy-to-use jQuery plugin.
Contents
Overview
jQuery MultiSelect is a configurable plugin for jQuery. It is designed to turn ordinary multi-select form controls into user-friendly dropdown lists. Check out the demo to see an example.
This project was inspired by arco90’s MultiSelect tool, but was written entirely from scratch to make it easier to implement, more accessible, and to shorten the code length.
This project is in beta testing and may not be ready for production use yet! See the to do list for more information.
Features
- Produces valid XHTML
- Fully customizeable via CSS
- Easy to configure and implement
- Degrades gracefully
- Keyboard shortcuts to maximize accessibility
- Optional “Select All” for convenience
Compatibility
This plugin requires jQuery 1.2.6 or above and has been tested to work in the following browsers:
- Internet Explorer 6 & 7
- Firefox 2 & 3 (beta)
- Safari 3
- Chrome (beta)
- Opera 9
Demo
View a live demonstration of jQuery MultiSelect.
Download
Current version: Version 1.0.2 beta (10 May 2009)
This plugin is provided to you as-is, at absolutely no cost. If you would like to support its development, feel free to contribute any amount you prefer via PayPal. As always, you are welcome to contribute code for bug fixes and feature enhancements as well. Either way, thanks for supporting our efforts!
Usage
Creating
In it’s simplest form, you can create a MultiSelect form control using the following code:
$("#control_id").multiSelect();
});
where #control_id is the ID of the select element that exists on your page. You can use any valid jQuery selector as the ID, but make sure you only use select elements with the multiple="multiple" attribute to get the expected results.
Configuring
Parameters are passed as an object to the multiSelect() function. Valid options include:
| Parameter | Description | Default Value |
|---|---|---|
| selectAll | whether or not to display the “Select All” option | true |
| selectAllText | text to display for selecting/unselecting all options simultaneously | Select All |
| noneSelected | text to display when there are no selected items in the list | 'Select options' |
| oneOrMoreSelected | text to display when there are one or more selected items in the list (note: you can use % as a placeholder for the number of items selected). Use * to show a comma separated list of all selected items | '% selected' |
To create a MultiSelect control with multiple parameters, your code will look something like this:
$("#control_id").multiSelect({
selectAll: false,
noneSelected: 'Check some boxes!',
oneOrMoreSelected: '% options checked'
});
});
Styling
The MultiSelect plugin relies 100% on CSS for styling. To give your users an aesthetically pleasing experience, you should either use the included stylesheet or create your own. Refer to jquery.multiSelect.css to make any changes in the styles.
Callback
If you specify a callback function, the MultiSelect control will execute it whenever a checkbox’s checked state is changed. Currently, the function passes the checkbox element that was clicked as a jQuery object. To specify a callback function, your code will look something like this:
$("#control_id").multiSelect(options, function() {
alert('Something was checked!');
});
});
where options is either null or a JavaScript object (see configuring for details).
To Do List
As jQuery MultiSelect is still in beta testing, there is an actively-updated to do list. To add something to the list or to contribute to the project in any way, please contact me using our contact form. You will receive appropriate credit for any and all contributions you make to this project, however you must agree that all code you submit will fall under the same license as the jQuery MultiSelect project.
What’s Left?
- Hide dropdown on a click that occurs outside of the dropdown/textbox
- Remove textbox selection when focusing on textbox
- “Select All” checkbox should be checked when all options get selected manually
Known IE6 Differences
- select layering bug (here is one possible solution that can be applied to your HTML/CSS)
- Max-height doesn’s work (unsupported CSS property)
- Clicking on labels won’t trigger the checkbox (normal browser behavior)
Licensing & Terms of Use
This plugin is dual-licensed under the GNU General Public License and the MIT License and is copyright 2008 A Beautiful Site, LLC.













Comments
— Jason on May 2nd, 2008
— Dezo on May 4th, 2008
— Cory S.N. LaViska on May 5th, 2008
— Jon on May 22nd, 2008
— chester on May 23rd, 2008
— sezer on Jun 3rd, 2008
— Paul on Jun 16th, 2008
— Cory S.N. LaViska on Jun 16th, 2008
— Paul on Jun 17th, 2008
— Andrew Dyer-Smith on Jul 5th, 2008
— Natesh on Jul 14th, 2008
— Cory S.N. LaViska on Jul 14th, 2008
— Nathan Smith on Jul 16th, 2008
— Natesh on Jul 28th, 2008
— Gary on Aug 22nd, 2008
— Stan on Aug 22nd, 2008
— rav on Aug 22nd, 2008
— Cory S.N. LaViska on Aug 24th, 2008
— Mike on Aug 27th, 2008
— Kevin on Sep 18th, 2008
— Kevin on Sep 18th, 2008
— Fredrik on Sep 25th, 2008
— James on Oct 3rd, 2008
— Ben on Oct 11th, 2008
— Cynthi on Oct 31st, 2008
— Webdesign Meppel on Nov 3rd, 2008
— samet on Nov 5th, 2008
— Rachit on Nov 5th, 2008
— Cory S.N. LaViska on Nov 5th, 2008
— samet on Nov 5th, 2008
— Steve on Nov 5th, 2008
— Cory S.N. LaViska on Nov 5th, 2008
— samet on Nov 7th, 2008
— nla on Nov 12th, 2008
— JOhn on Dec 8th, 2008
— Caner on Dec 8th, 2008
— ben on Dec 10th, 2008
— ado on Dec 13th, 2008
— ben on Dec 18th, 2008
— Felipe on Dec 24th, 2008
— derek on Dec 30th, 2008
— Mahesh on Jan 2nd, 2009
— Mahesh Dasari on Jan 5th, 2009
— Marc on Jan 11th, 2009
— misha antsibor on Jan 12th, 2009
— misha antsibor on Jan 12th, 2009
— misha antsibor on Jan 12th, 2009
— Cory S.N. LaViska on Jan 12th, 2009
— Matt Elliott on Jan 15th, 2009
— Matt Elliott on Jan 15th, 2009
— wofei on Jan 17th, 2009
— Jeff Handley on Jan 18th, 2009
— kumar on Jan 20th, 2009
— fehays on Jan 26th, 2009
— fehays on Jan 26th, 2009
— Seetharaman Srinivasan on Jan 28th, 2009
— Matthew on Feb 5th, 2009
— Hemant on Feb 9th, 2009
— BogeyBill on Feb 12th, 2009
— kiki on Feb 13th, 2009
— timidllama on Feb 15th, 2009
— Hemant on Feb 16th, 2009
— Ben Strackany on Feb 17th, 2009
— Richard Hayes on Feb 18th, 2009
— Shrikanth Kalluraya on Feb 26th, 2009
— Peter on Feb 26th, 2009
— Jono Ward on Mar 5th, 2009
— Ann on Mar 11th, 2009
— Erick on Mar 19th, 2009
— Mohamed on Mar 23rd, 2009
— Ioldanach on Apr 7th, 2009
— John Rice on Apr 8th, 2009
— kapil on Apr 9th, 2009
— Cédric on Apr 9th, 2009
— afa on Apr 28th, 2009
— Sanbor on May 4th, 2009
— zamir dan on May 4th, 2009
— Jon B on May 7th, 2009
— fabrice.regnier on May 7th, 2009
— fabrice.regnier on May 7th, 2009
— Matt on May 11th, 2009
— Utopia on May 15th, 2009
— salud on May 15th, 2009
— Michael Aufreiter on May 18th, 2009
— Kristian Chakarov on May 25th, 2009
— Mike on May 26th, 2009
— Guzmán Brasó on May 26th, 2009
— Guzmán Brasó on May 26th, 2009
— FrogDr on May 27th, 2009
— Abhisheak on May 27th, 2009
— Alston on Jun 4th, 2009
— Scott on Jun 9th, 2009
— axel on Jun 16th, 2009
— Paul on Jun 16th, 2009
— Paul on Jun 16th, 2009
— pegen on Jun 17th, 2009
— fmonera on Jun 20th, 2009
— fmonera on Jun 20th, 2009
— Andrew Lundgren on Jun 26th, 2009
— Andrew Lundgren on Jul 1st, 2009