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
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
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.
THANK YOU VERY MUCH!!! I SUCCED!
but, in a very strange way, i needed to write it the opposite way:
export function switch1_click(event) {
if ($w(‘#switch1’).checked)
$w(‘#group52’).collapse()
else
$w(‘#group52’).expand()
}
when I wrote “if checked - expand” its expand when the switch is off, instead of when the switch is on… vice versa
do you understand why?
Strange indeed.
Could you post a link to your site/editor so I can take a look?
Doron.
@doron-alkalay ofcourse
you speak hebrew, right?
it is in the section of “סקירה כללית”
i changed the switch button into checkbox
How did you enable the Facebook chat plugin?
@carlosgalvarez
you go to your facebook page >>
setting >>
in the side menu “messenger platform”
and the choose “chat plugin with customers”
and then you get a code to put in your site
if you need more help tell me!
Hi!
Indeed I can (read Hebrew) although I cant seem to find the section you’ve mentioned.
Please state the page it is located on.
Doron.
@doron-alkalay
הטיפולים >>
אבחנה סינית
DIRECT LINK:
https://www.eleflayla.com/online-questionnaire
Slide #3
i think the buttons didn’t work before, now i’ve fixed that