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:
- Store the value of the
options
property in a variable. - Make changes to the array.
- Reset the
options
property with the modified array.
Note: Setting the
options
property clears thevalues
that do not match the newoptions
.
Type:
NAME
TYPE
DESCRIPTION
The value of the selection tag option. This is what you use in code and is what is stored in your collections.
The label of the selection tag option. This is what a site visitor sees.
Was this helpful?
1let selectionTagsOptions = $w("#mySelectionTags").options;23let firstLabel = selectionTagsOptions[0].label; // "First Label"4let firstValue = selectionTagsOptions[0].value; // "first_value"
1$w("#mySelectionTags").options = [2 { 'label': 'Onion', 'value': 'onion'},3 { 'label': 'Tomatoes', 'value': 'tomatoes'},4 { 'label': 'Extra Cheese', 'value': 'cheese'}56];
This example retrieves the options of selection tags, adds a new option, and then overwrites the old options.
1let pizzaToppingOptions = $w("#pizzaToppingTags").options;2pizzaToppingOptions.push({"label": "Olives", "value": "olives"});3$w("#pizzaToppingTags").options = pizzaToppingOptions;4