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.

Properties

form

Syntax: object.form

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

length

Syntax: object.length

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

name

Syntax: object.name

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

options

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.

selectedIndex

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.

type

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.

Methods

blur

Syntax: object.blur()

This method removes focus from a selection list.

focus

Syntax: object.focus()

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

handleEvent

Syntax: object.handleEvent(event)

This method calls the handler for a specified event.

See Also: