Option([text[, value[, defaultSelected[, selected]]]])
An Option object is created for every option in a selection
list, and is put in the options property of the Select
object. It can be created in one of two ways: you can either use the
HTML <OPTION> tag, or use the Option constructor. Using
HTML you could create a 'Dachshund' option for a selection list of dog
breeds as follows:
You could also create the same option using the Option constructor
and assigning it to an index of the options property of the relevent
document.myForm.dogBreed = new Option("Dachshund")
After creating an Option object in this way you must refresh
the document by using history.go(0) at the end of the code. Using
the Option constructor, you can optionally specify a value to
be returned to the server when an option is selected and the form submitted
(in this case "dachs"):
new Option("Dachshund", "dachs")
It is also possible to designate the option to be the pre-selected default selection
in the option box display (i.e., this option has the HTML "selected" attribute included
inside the "option" tag).
This is done by setting the defaultSelected argument to be true.
new Option("Dachshund", "dachs", true)
The selected argument is used for multiple selections.
This property, by default tainted, is a Boolean value which initially
reflects whether an option was declared with the HTML SELECTED attribute,
reading true if it was and false if not
This property, which is tainted by default, is a Boolean value reflecting
whether a particular option is selected, returning true if it
is and false if not. The selected property can be set
at any time, immediately updating the display of the Select object.
This property, by default tainted, reflects the text value following
any particular HTML OPTION tag for a Select object. It can be
reset at any time, immediately updating the display of the selection.
This property, tainted by default, is a string value that is returned
to the server when an option is selected and the form submitted. It
reflects the VALUE attribute in the HTML. If there is no VALUE attribute,
then the value property is an empty string.
The Select object inherits the watch
and unwatch methods from the