A standard listbox component with a whole slew of features that affect it's look-and-feel. Supports multiple selection, sorting, drag-n-drop and more.
The Listbox has a property named items which can be treated as a NodeArray. You can access each item in
the list using array notation, such as Listbox1.items.[0].innerHTML="boo"
This would set the text of the first item in the list. Take care not to try to access an item that doesn't exist. You can use
items.length to determine how many items are in the list. (remember that the array starts with zero,
not one!)
The listbox has a method named addItem() which takes an an inline object as a parameter. This argument controls how an item is created.
For example:
Fires right before the onchange event. You can return false to stop the selection from taking place. If you do, the onchange event will not fire. item is the item the user is selecting. NOTE: You must return true from this event to allow the selection to take place.
The "arg" parameter fed to this method is an inline Object. See below for accepted parameters. Any parameters not listed here that you add may also be attached to any returned Object.
Adds an item to the list.
Caption can be plain-text or HTML.
Can optionally fire a function when the item is selected.
This method takes in a character delimited string and creates an item for each entry. For example, passing in the string
"red,white,blue" would cause the listbox to add three items of the cooresponding captions.
The default delimiter a comma, or you can specify another to use.
Attempts to locate an item in the list. Returns a pointer to the item or null if not found.
By default searches are case-sensitive. Pass true as the second parameter for
case-insensitive searches.
Example:
var myItem = listbox1.findItem("boat",true); // search for mixed-case "boat"
if(myItem != null) alert("found a boat!");
This method will overwrite an existing item. Params are the same as addItem() with the exception
of the first which is the index of the item to overwrite. The first item in the list is item number zero.
If set to false, the control will not allow there to ever be less than one selected node. The first node added to the list will be immediately selected.
Example:
listbox1.allowNoSelect = true; // user can deselect all items