Change tabs with switch widget instead of buttons

Hi!
I'm aware I can change tabs within a container through a button's script.
I would like to do the same, but using a switch. Changing the switch value, would change the tab.

I've created a switch widget (switch_menu). Then created a script widget (script_menu). Then, on the script_menu script I filled the following:

if ('switch_menu'===0)
{
set ('panel_main',0)
}
if ('switch_menu'===1)
{
set ('panel_main',1)
}

This however, doesn't produce any results. Would appreciate if someone could lead me in the right path. Thanks!

Use the switch widget's onValue property directly:

if (value === 0) {
  // etc
} else if (value === 1) {
 // etc
}

Great!
Such a simple solution! Thank you!