options
Sets or gets the options in a radio button group.
Description
Setting the options
property sets all the options
available to a user in a radio button group.
options
is an array of option objects. Each
option object can contain a label
property, which is what the user sees, and a
value
property, which is what is used in code and stored in your collections.
Set options
to an empty array ([]
) to remove the current radio button group options.
Getting the options
property returns the current
list of options available to a user.
You cannot modify the data array in-place. To add, change, or remove individual radio button group options:
- Store the value of the
options
property in a variable. - Make changes to the options array.
- Reset the
options
property with the modified array.
Type:
NAME
TYPE
DESCRIPTION
The value of the radio button option. This is what you use in code and is what is stored in your collections. Mandatory if label
is not specified.
The label of the radio button option. This is what a user sees. Mandatory if value
is not specified.
Was this helpful?
1let radioOptions = $w("#myRadioGroup").options;23let firstLabel = radioOptions[0].label; // "First Label"4let firstValue = radioOptions[0].value; // "first_value"
1$w("#myRadioGroup").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"}5];
This example retrieves the options of a radio button group, adds a new option, and then overwrites the old options.
1let opts = $w("#myRadioGroup").options;2opts.push({"label": "New Label", "value": "New Value"});3$w("#myRadioGroup").options = opts;4