Search.../

options

Sets or gets a list of items which will be rendered as tags.

Description

Setting the options property sets all the options available to a site visitor.

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

Each option contains a label, which is what the site visitor sees, and a value, which is used in code and stored in your collections.

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

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

Note: Setting the options property clears the values that do not match the new options.

Type:

Array<Option>Read & Write, default value is An empty array
NAME
TYPE
DESCRIPTION
value
string

The value of the selection tag option. This is what you use in code and is what is stored in your collections.

label
string

The label of the selection tag option. This is what a site visitor sees.

Was this helpful?

Get the options of selection tags

Copy Code
1let selectionTagsOptions = $w("#mySelectionTags").options;
2
3let firstLabel = selectionTagsOptions[0].label; // "First Label"
4let firstValue = selectionTagsOptions[0].value; // "first_value"
Set the options of selection tags

Copy Code
1$w("#mySelectionTags").options = [
2 { 'label': 'Onion', 'value': 'onion'},
3 { 'label': 'Tomatoes', 'value': 'tomatoes'},
4 { 'label': 'Extra Cheese', 'value': 'cheese'}
5
6];
Add an option to selection tags

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

Copy Code
1let pizzaToppingOptions = $w("#pizzaToppingTags").options;
2pizzaToppingOptions.push({"label": "Olives", "value": "olives"});
3$w("#pizzaToppingTags").options = pizzaToppingOptions;
4