I should mention that to the best of my knowledge there is not a good way to trigger a toggle buttons style from script so I just keep the style in the api and tell the button what to do hence the ogscript.setStyle([ID],[style]). Here is another way to do it that simply uses params and a task in the button. keep in mind just use a button instead of a param that looks like a button. You have a bit more flexibility that way. Good luck dude.
<abs contexttype="opengear" id="_top" keepalive="false" style="">
<meta>
<params>
<param access="1" constrainttype="INT_CHOICE" name="ToggleButton" oid="ToggleButton" precision="1" type="INT16" value="0" widget="toggle">
<constraint key="0"/>
<constraint key="1"/>
</param>
</params>
</meta>
<button buttontype="push" height="337" id="Toggle_Button" left="61" name="This button is off" top="68" width="605">
<task tasktype="ogscript">var name = {on:'This button is on', off:'This button is off'};// names to be used if on or off
var style = {on:'bg#selectbg', off:'bg#buttonbg'}
var value = params.getValue('ToggleButton', 0);//what is the current state of the param
var button = component.getClientProperty('id');//what is the name of this button
if(value == 0){// if the param is off do this
ogscript.rename(button, name['on']);//rename this button
params.setValue('ToggleButton', 0, 1);//set the param value to on
ogscript.setStyle(button, style['on'])
}else{
if(value == 1){ //if the param is on do this
ogscript.rename(button, name['off']);// rename the button the off value
params.setValue('ToggleButton', 0, 0);
ogscript.setStyle(button, style['off'])
}
}
</task>
</button>
</abs>
#DashBoard