GetAllSelectedOptions - web automation method

Retrieves the collection of selected options in a HTML list-box ( IHTMLSelectElement ) control.

Applies to:
  var optionsList = elementObj.GetAllSelectedOptions();
If no option is selected inside dropdown/list-box then an empty IE automation ElementList object is returned after searchTimeout has expired. It can be applied only to <select> objects, otherwise a script exception is thrown and the lastError property is set to INVALID_OPERATION_ERROR.

The time allocated for finding the selected options list is specified by the searchTimeout property. If loadTimeout is not zero, then the method waits the browser objects to be completely loaded in the amount of time specified by the property. If the timeout has expired the lastError property is set to LOAD_TIMEOUT_ERROR. In this case, if loadTimeoutIsError property is true, then a IE macro exception is thrown.
// Displays all selected options in a select object.
var coreObj = new ActiveXObject("OpenTwebst.Core");
var browser = coreObj.StartBrowser("");
var select  = browser.FindElement("select", "");
var optList = select.GetAllSelectedOptions();
var text    = "";

for (var i = 0; i < optList.length; ++i)
	text += optList.item(i).uiName;
	text += "\n";

See also:
AddSelection | AddSelectionRange | ClearSelection | Element | ElementList | Select | selectedOption | SelectRange

© 2017 CodeCentrix Software. All rights reserved.