Name
Option
Synopsis
select.options[i]
Constructor
In JavaScript 1.1 and later, Option objects can be created
dynamically with the Option( ) constructor:
new Option(text,value,defaultSelected,selected)
Properties
-
defaultSelected A read/write boolean that specifies whether the option is initially selected when the Select object that contains it is created or reset.
-
index A read-only integer that specifies the index of the option within the
options[ ]array of the Select object that contains it.-
selected A read/write boolean value that specifies whether an option is currently selected. You can use this property to test whether a given option is selected. You can also set it to select or deselect an option. Note that when you select or deselect an option in this way, the
Select.onchange( )event handler is not invoked.-
text A read/write string that specifies the text that appears to the user for the option.
-
value A read/write string that specifies the text that is passed to the web server if the option is selected when the form is submitted.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access