Sets or gets the options in a dropdown.


Setting the options property sets all the options available to a user.

Set options to an empty array ([]) to remove the current dropdown options.

Getting the options property returns the current list of options available to a user.

You cannot modify the options array in-place. To add, change, or remove individual dropdown options:

  1. Store the value of the options property in a variable.
  2. Make changes to the options array.
  3. Reset the options property with the modified array.


Array<Option>Read & Write, default value is An empty array

Was this helpful?

Get the list of options and the first option's label and value from dropdown

Code Example

Copy Code
1let dropdownOptions = $w("#myDropdown").options;
3let firstLabel = dropdownOptions[0].label; // "First Label"
4let firstValue = dropdownOptions[0].value; // "first_value"
Set the list of options for a dropdown

Code Example

Copy Code
1$w("#myDropdown").options = [
2 {"label": "Who's on first!", "value": "first"},
3 {"label": "What's on second", "value": "second"},
4 {"label": "I Don't Know is on third", "value": "third"}
Add an option to a dropdown

This example retrieves the options of a dropdown, adds a new option, and then overwrites the old options.

Code Example

Copy Code
1let opts = $w("#myDropdown").options;
2opts.push({"label": "New Label", "value": "New Value"});
3$w("#myDropdown").options = opts;