Use Javascript to update radioGroup or TabbedContainer

Hi all,

I would like to use javascript to update a radioGroup and a tabbed container by clicking on a button. In particular I want to add more options to the radio group and add more tabs to the tabbed container.


So I want something like

radioGroup1.values['3'] = "Option 4"

Or similar something like

tabbedContainer1.views['3'] = { ... }

I am familar with Python but new to javascript. Is that possible with Retool?

Here is an example using Temporary states

Sample app: Dynamic RadioGroup.json (16.8 KB)


The default Temporary state content

Use the temporary state as radio group source

And finally the script to add a value to the list

const values = stateOptions.value
const newValue = {
  value: textInput1.value,
  label: `Option ${textInput1.value}`
stateOptions.setValue([...values, newValue])
1 Like

Fantastic!! Works exactly as described! Thanks for the detailed explanation!

PS: The "stateOptions.setValue" command failed for me but after refreshing the page, it worked fine.