selectedIndex property (options, keygen, select)
Specifies or returns the zero-based index of the selected option in a select object or in the selection list of a keygen object.
If multiple selection is allowed in the select object, than the selectedIndex property returns the index of the first selected option. If no option is selected, the selectedIndex property contains -1.
If you need to specify or retrieve the selected items in a multiple selection list box, you can use the selected property. You can find a detailed description and examples on the page for the selected property.If you want to specify only one selected element in a multiple-selection list or a selected element in a single-selection list, you can do it in the following ways:
You can find the related objects in the Supported by objects section below.
This property is read/write.
Zero-based Integer, the selected option.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the selectedIndex property:
Did you find this example helpful?
User Contributed Comments