SCRIPTING SELECT BOXES
Select boxes are created using the <select>
and <option>
elements. To allow for easier interaction with the control, the HTMLSelectElement
type provides the following properties and methods in addition to those that are available on all form fields:
add(newOption, relOption)
—Adds a new<option>
element to the control before the related option.-
multiple
—A Boolean value indicating if multiple selections are allowed; equivalent to the HTMLmultiple
attribute. options
—AnHTMLCollection
of<option>
elements in the control.remove(index)
—Removes the option in the given position.selectedIndex
—The zero-based index of the selected option or–1
if no options are selected. For select boxes that allow multiple selections, this is always the first option in the selection.size
—The number of rows visible in the select box; equivalent to the HTMLsize
attribute.
The type
property for a select box is either...