O'Reilly logo

JavaScript Pocket Reference, 2nd Edition by David Flanagan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

Select

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required