JavaScript » Objects » Select

The Select object represents a selection list in a Form object. As such, it must be declared inside <FORM> tags. The JavaScript runtime engine creates such an object for every selection list in a particular form, and assigns it to the Form's elements array. It is through this array that a particular Select object can be accessed, either by index-number or by its NAME attribute.



Syntax: object.form

This property is a reference to the parent form to which a particular Select object belongs.


Syntax: object.length

This property contains the number of options in the selection list.



This property consists of a string which gives the name of the selection.


Syntax: object.options

This property is an array of all the options in a particular Select object. There is one element (numbered in ascending order from zero) for each <OPTION> tag.


Syntax: object.selectedIndex

This property, which is tainted by default, is an integer relating to the currently-selected option of a Select object. If, however, the Select object allows for multiple selections (i.e. when the <SELECT> tag includes the MULTIPLE attribute), the selectedIndex property will only return the index of the first option selected.


Syntax: object.type

This property holds the type of the Select object, having the value "select-one" where only one option can be selected and "select-multiple" where multiple selections are possible.



Syntax: object.blur()

This method removes focus from a selection list.


Syntax: object.focus()

This method moves the focus to the specified selection list allowing the user to then select from it.


Syntax: object.handleEvent(event)

This method calls the handler for a specified event.

See Also: