Definition
Indicates an option in the select element.
Denotes one choice in a select element.
Note
In Internet Explorer 5 and later versions, the option element is part of the all set. In earlier versions, you can only access these elements through the options set of select elements.
You can only add option elements to select elements in the same window as option.
Except for background-color and color, style settings specified for the option element are ignored. In addition, the style directly applied to a single options will overwrite the style applied to the select element container.
This element is available in HTML and script of Internet Explorer 3.0 and later versions.
This element is a block element.
The label does not need to be disabled for this element.
As of Internet Explorer 5 and later, the option elements are part of the All collection. For earlier versions, you can gain access to these elements by applying the options collection to the select element.
You can add option elements only to a select element that is located in the same window where the option elements are created.
Except t for background-color and color, style settings applied through the style object for the option element are ignored. in addition, style settings applied directly to individual options override those applied to the containing select element as a whole.
This element is available in HTML and script as of Internet Explorer 3.0.
This element is a block element.
This element does not require a closing tag.
Example Code
The following example uses the option element to create a single project in the drop-down list box.
<Select id = "ocars" size = "1" onchange = "fnchange ()">
<Option value = "1"> BMW
<Option value = "2"> Porsche
<Option value = "3" selected> Ben
</SELECT>
<Textarea id = "odata"> </textarea>
The following example uses the options set to append the selected items in the list box to the text area.
<Script language = "jscript">
Function fnchange (){
Odata. Value + = ocars. Options [ocars. selectedindex]. Text + "\ n ";
}
</SCRIPT>