JavaScript Option Object

The JavaScript Option object is a property of the form object. It is one of several options in a selection box. It appears inside a select box as follows:

<SELECT NAME="state" SIZE=0>
	<OPTION VALUE="0">
	<OPTION VALUE="1">AL
	<OPTION VALUE="2">AK
	<OPTION VALUE="3">AR
</SELECT>

It looks like:

Properties

  • defaultSelected - Is a boolean value determining whether the option is selected by default. Read only.
  • index - The index of the option in the list of selections. Read only.
  • selected - Determines if the option is currently selected. This boolean value is read/write.
  • text - The text used to describe the option.
  • value - The value sent to the server if the option was selected.
  • prototype - Used to create additional properties.

Methods

  • blur()- Remove the focus from the option.
  • focus() - Give the focus to the option.

Events

  • onBlur
  • onChange
  • onFocus