Search.../

selectedIndex

Sets or gets the index of the selected option.

Description

Setting the selectedIndex property sets the option at that index to be the selected option. To set one of the options to be selected, set the selectedIndex property to an index between 0 and options.length - 1.

To reset the dropdown to have no option selected, set the selectedIndex property to undefined.

Getting the selectedIndex property returns the index of the currently selected option. If no value is selected, the selectedIndex property returns undefined.

Type:

numberRead & Write

Was this helpful?

Get the index of the selected option

Copy Code
1let dropdownSelIndex = $w("#myDropdown").selectedIndex; // 3
Select the first option by index

Copy Code
1$w("#myDropdown").selectedIndex = 0;