Availability: |
| ||||||||
Inherits from: | Element object | ||||||||
JavaScript syntax: | - | myOption = myDocument.aFormName.aSelectorName.options[anIndex] | |||||||
- | myOption = myDocument.aFormName.elements[anItemIndex].options[anIndex] | ||||||||
IE | myOption = myDocument.all.anElementID | ||||||||
IE | myOption = myDocument.all.anElementID.elements[anIndex].options[anIndex] | ||||||||
IE | myOption = myDocument.all.anElementID.options[anIndex] | ||||||||
IE | myOption = myDocument.all.tags("OPTION")[anIndex] | ||||||||
IE | myOption = myDocument.all[aName] | ||||||||
- | myOption = myDocument.forms[aFormIndex].aSelectorName.options[anIndex] | ||||||||
- | myOption = myDocument.forms[aFormIndex].elements[anIndex].options[anIndex] | ||||||||
- | myOption = myDocument.getElementById(anElementID) | ||||||||
- | myOption = myDocument.getElementsByName(aName)[anIndex] | ||||||||
- | myOption = myForm.aSelectorName.options[anIndex] | ||||||||
- | myOption = myForm.elements[anItemIndex].options[anIndex] | ||||||||
- | myOption = myOptionsArray[anIndex] | ||||||||
- | myOption = mySelector.options[anIndex] | ||||||||
- | myOption = myDocument.getElementsByTagName("OPTION")[anIndex] | ||||||||
HTML syntax: | <OPTION> ... </OPTION> | ||||||||
Argument list: | anIndex | A valid reference to an item in the collection | |||||||
anItemIndex | A valid reference to an item in the collection | ||||||||
aName | The name attribute of an element | ||||||||
aFormIndex | A reference to a particular form in the forms collection | ||||||||
anElementID | The ID attribute of an element | ||||||||
Object properties: | defaultSelected, form, index, label, prototype, selected, text, value | ||||||||
Event handlers: | onClick, onDblClick, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp |
In Netscape, this sub-class of the Input object supports a couple of properties that may not be available on other platforms.
The DOM level 1 specification calls this object type an OptionElement object.
In Netscape, this object is easy to confuse with the Select object to which the options belong. Be careful to maintain the correct structural relationship between Select popup menus and their option sets.
Netscape 6.0 PR3 exhibited some instabilities in the support of this object. However, it is not certain whether the bug is still outstanding on the final release as well. The problem seemed related to the creation of new Option objects by means of the constructor. This is not something that everyone is going to be doing on all their pages so its not likely to be a show stopper unless its just that one thing you need to use.
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
defaultSelected | 1.1 ![]() | 1.0 ![]() | 3.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
form | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | 1 ![]() | ![]() | ![]() | ![]() |
index | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
label | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
prototype | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
selected | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
text | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | 1 ![]() | ![]() | ![]() | ReadOnly. |
value | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
Event name | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
onClick | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onDblClick | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onHelp | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
onKeyDown | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onKeyPress | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onKeyUp | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onMouseDown | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onMouseMove | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onMouseOut | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onMouseOver | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
onMouseUp | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | 4.0 ![]() | ![]() |
Prev | Home | Next |
OptGroupElement.label | Up | Option() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |