getAllOptions() |
It returns all the options that are available in the Select and List controls.
Syntax
Script |
optionsCollection = ControlID getAllOptions() |
Parameters
Parameter |
Description |
---|---|
optionCollection |
Denotes the options available for the select and list controls. |
Remarks
This method returns an array of options available in a Select or List control. You can also use this method to check the availbility of an option. This is especially useful to avoid adding duplicate options in your Web page.
Example
The following sample code demonstrates how the method can be used to retrieve a list of available options and to check whether an option is already present or not.
function isOptionAlreadyPresent(option, selectControl) { //get the list of options in the Select control var allOptions = selectControl.getAllOptions(); //check if an option is already available for (var index = 0; index < allOptions.length; index++) { var currentOption = allOptions[index]; if (currentOption.value == option.value && currentOption.description == option.description) return index; } return null; }