Sets or retrieves the index of the selected option in a select object.
HRESULT IHTMLSelectElement::get_selectedIndex(long *p);HRESULT IHTMLSelectElement::put_selectedIndex(long v);
- Pointer to a variable of type long that receives the index.
- long that specifies the index.
Returns S_OK if successful, or an error value otherwise.
Options in a select object are indexed in the order in which they are defined, starting with an index of 0. When you set the IHTMLSelectElement::selectedIndex property, the display of the select object updates immediately.
The IHTMLSelectElement::selectedIndex property returns -1 if a select object does not contain any selected items. Setting the selectedIndex property clears any existing selected items.
The IHTMLSelectElement::selectedIndex property is most useful when used with select objects that support selecting only one item at a time—that is, those in which the MULTIPLE attribute is not specified. If the MULTIPLE attribute is specified for a select object, the IHTMLSelectElement::selectedIndex property returns only the index of the first selected item, if any.
The IHTMLOptionElement::selected property is most useful when used with select objects that support selecting more than one item at a time—that is, those in which the MULTIPLE attribute is specified. You can use the IHTMLOptionElement::selected property to determine whether an individual item in a select object is selected. In addition, selected items are not cleared when the IHTMLOptionElement::selected property is set. This allows multiple items in the list to be selected at the same time.