Plugin JQuery jSelect - Usage Exemples

This plugin enables to manage Select elements in forms. Offers possibility to add options from an Array, a XML file or JSON data, or even, directly from the Select with a prompt.

New! Correct a little bug with loading type (post / get) and add example to auto-populate a Select element.

New! jSelect was updated to work with new jQuery 1.3.2 and to add possibility to create options with a plain array. Download jSelect 1.3.1

Usage

jQuery jSelect requires jQuery 1.2 or above.

							$('#array_plus_xml_select').jselect({
								data: [ "Option Zero", [ 1, "Option One", true, "my-class" ] ],
								replaceAll: true,
								loadUrl: "jselect.xml",
								addOption: true,
								addOptionUrl: "new-option.php"
							});
						

Examples

Replace options in place with data from JS Array, XML file and directly from the Select with a prompt.

Before:

                                <select name="array_plus_xml_select" id="array_plus_xml_select">
                                    <option value="0">Loading...</option>
                                </select>
							

You can now use a multidimensional, plain or mixed array.

Examples:

var plainArray = new Array("Option Zero", "Option One");

var multiArray = [ [ 0, "Option Zero", false, "" ] , [ 1, "Option One", true, "my-class" ] ];

var mixedArray = [ "Option Zero" , [ 1, "Option One", true, "my-class" ] ];


Auto-populating Select element.

Allow the user to select a top level category from one Select box and to automatically populate the sub-category.

Here, I added some options in the sub-category on category change by loading JSON datas with AJAX.
But you can manage a plain/complex Array or XML datas, with/without Ajax.


Add options from JSON datas, and manage events.

Before:

								<select name="json_select" id="json_select">
									<option value="0">Option Zero</option>
									<option value="1">Option One</option>
									<option value="2">Option Two</option>
								</select>
							


Last selected?  

Documentation

Download

A comment?

Until I put up the comments...