Option

The option object refers to an option in a select element of a form—either a pull-down menu or scrollable list. All the options of a select element are stored in the options[] array of that element.

Properties

Form

FF, IE 3

Form containing the option

selected

FF, IE 3

true if the option has been selected and false otherwise

Example:

if (window.document.the_form.the_pulldown.options[0].selected == true)
{
    var the_option_text =
        window.document.the_form.the_pulldown.option[0].text;
    alert("thanks for picking " + the_option_text);
}

text

FF, IE 3

Text associated with an option (see the preceding example)

value

FF, IE 3

Value of the option

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.