Forums

Checkboxes and event switcher

pat01 12 Jul, 2019
Hi

I have two checkboxes:

Name: yourselection[]

Values:
0=AAA
1=BBB

And I have following action:

Event switcher
Data provider: {data:yourselection}
Events:
0
1

In both switches I have custom code.

But no matter what checkbox I tick, switching is not working.

Having both custom codes outside of the switcher = custom code is shown = custom code is OK.

The debugger shows following if checkbox 0 is ticked:
[yourselection] => Array
(
[0] => 0
)

and for checkbox 1:
[yourselection] => Array
(
[0] => 1
)

So values are passed.

What do I have to change to make the event switcher to work with checkboxes?

Thanks a lot!

Patrick
healyhatman 12 Jul, 2019
Because yourselection[] is an ARRAY, not a single value. So yourselection will never equal 0 or 1, it will CONTAIN 0 or 1.

You need to use If Conditions instead, looking for your value being IN {data:yourselection}
healyhatman 12 Jul, 2019
Answer
Although just now realising that Max made the IN condition wrong.

Just do it in PHP instead. Check if in_array(0, $this->data("checkboxesname"))
pat01 15 Jul, 2019
Thanks a lot, works fine!
This topic is locked and no more replies can be posted.