WARNING: Most of this content (with the exception of the Mozilla 1.9 XPCOM reference) is very old, and can be expected to be out of date and possibly obsolete. For better XUL documentation, please visit the XUL hub at the Mozilla Developer Center.

nsISelectElement

IID:35bd8ed5-5f34-4126-8c4f-38ba01681836
Inherits From:nsISupports

This interface is used to notify a SELECT when OPTION elements are added and removed from its subtree. Note that the nsIDOMHTMLSelectElement and nsIContent interfaces are the ones to use to access and enumerate OPTIONs within a SELECT element.


Properties

readonly PRBool hasOptGroups


Methods

PRInt32 getOptionIndex ( nsIDOMHTMLOptionElement option , PRInt32 startIndex , PRBool forward ) PRBool isOptionDisabled ( PRInt32 index ) PRBool setOptionsSelectedByIndex ( PRInt32 startIndex , PRInt32 endIndex , PRBool isSelected , PRBool clearAll , PRBool setDisabled , PRBool notify ) [noscript] void willAddOptions ( nsIContent options , nsIContent parent , PRInt32 contentIndex ) [noscript] void willRemoveOptions ( nsIContent parent , PRInt32 contentIndex )

PRInt32 getOptionIndex ( nsIDOMHTMLOptionElement option , PRInt32 startIndex , PRBool forward )

Finds the index of a given option element

Arguments:
option: the option to get the index of
startIndex: the index to start looking at
forward: TRUE to look forward, FALSE to look backward
Returns:
the option index

PRBool isOptionDisabled ( PRInt32 index )

Checks whether an option is disabled (even if it's part of an optgroup)

Arguments:
index: the index of the option to check
Returns:
whether the option is disabled

PRBool setOptionsSelectedByIndex ( PRInt32 startIndex , PRInt32 endIndex , PRBool isSelected , PRBool clearAll , PRBool setDisabled , PRBool notify )

Sets multiple options (or just sets startIndex if select is single) and handles notifications and cleanup and everything under the sun. When this method exits, the select will be in a consistent state. i.e. if you set the last option to false, it will select an option anyway.

Arguments:
startIndex: the first index to set
endIndex: the last index to set (set same as first index for one option)
isSelected: whether to set the option(s) to true or false
clearAll: whether to clear all other options (for example, if you are normal-clicking on the current option)
setDisabled: whether it is permissible to set disabled options (for JavaScript)
notify: whether to notify frames and such
Returns:
whether any options were actually changed

void willAddOptions ( nsIContent options , nsIContent parent , PRInt32 contentIndex )

To be called when stuff is added under a child of the select--but *before* they are actually added.

Arguments:
options: the content that was added (usually just an option, but could be an optgroup node with many child options)
parent: the parent the options were added to (could be an optgroup)
contentIndex: the index where the options are being added within the parent (if the parent is an optgroup, the index within the optgroup)

void willRemoveOptions ( nsIContent parent , PRInt32 contentIndex )

To be called when stuff is removed under a child of the select--but before* they are actually removed.

Arguments:
parent: the parent the option(s) are being removed from
contentIndex: the index of the option(s) within the parent (if the parent is an optgroup, the index within the optgroup)

Reference documentation is generated from Mozilla's source.