OPTION Element | OPTION Object
Denotes one choice in a SELECT element.
HTML Syntax
<OPTION CLASS=classname ID=value LANGUAGE=JAVASCRIPT | JSCRIPT | VBSCRIPT | VBS SELECTED VALUE=value event = script >
Remarks
Although OPTION elements do not appear in the all collection, 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 located in the same window where the OPTION elements are created.
Except 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.
The OPTION element does not require a closing tag.
This element is available in HTML and script as of Microsoft® Internet Explorer 3.0.
Members
Styles
Example
This example uses the OPTION element to create individual items in a drop-down list box.
<SELECT ID="oCars" SIZE="1" onchange="fnChange()"> <OPTION VALUE="1">BMW <OPTION VALUE="2">PORSCHE <OPTION VALUE="3" SELECTED>MERCEDES </SELECT> <TEXTAREA ID="oData"></TEXTAREA>This example uses the options collection to append the selected item of the list box in a text area.
<SCRIPT LANGUAGE="JScript"> function fnChange(){ oData.value+=oCars.options[oCars.selectedIndex].text + "\n"; } </SCRIPT>
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.