Hi
Im trying to use the Switch button in a form,
and the goal is that when the Switch is on, a specific input element will expand (which is collapsed by default), and when the Switch is off again, the input element will collapse back again.
so, the first step is easy, I set the input element property in "collapsed on load"
and then I made an event handler:
export function switch1_click(event) { $w('#group50').expand() }
but after that, how can I make the input element collapse back again when I set the Switch button off?
thank you in advanced
Hi Liran!
It is right that according to the initial settings you'll get the expected behavior but if you want to use it as a long term option (might be more than one click at a session) you'll need to check the state of the switch button.
In the documentation you can see that one of the properties of this kind of button is 'checked( )'.
Using this button ability you should modify your code to something like this:
export function switch1_click(event) { if ($w('#switch1').checked) { $w('#group50').expand() } else $w("#group50").collapse() }
Now every time that the button is clicked, it will either expand the element if the value is "True" for the `checked` property, or collapse the element if it was switched off.
Hope that helps.
Doron.
You should either the the collapse status of the box or the switch status so your event will look like this:
if box is collapsed then expand else collapse