This topic is locked
[SOLVED]

 Reference multiple conditions to show/hide

8/25/2020 12:48:23 AM
PHPRunner General questions
woodey2002 author

Hi Guys
I would love someone to please tell me the following is possible.
I have a dropdown that has 4 options called "make"
It has 4 options...

Option A

Option B

Option C

Option D
Via Javascript, I use whichever option the user selects from the dropdown to show/hide some corresponding fields.
From the dropdown...
Show/hide 1 --- If a user chooses either Option A, Option B, Option C then show/hide some fields.
Show/hide 2 --- If a user chooses Option D, show/hide some different fields
I can get it to work beautifully on the add page but only partially on the edit page because of the multiple choices/options in Show/hide 1.
When working with show/hide JS on the edit page I usually use an event on before record updated event to set the value to "" if the dropdown did not contain the values needed after the show/hide.

I also use an event on the Before display event to display the the values if during add process the user chose the triggering values.
This works really well most of the time with unique conditions but because Show/hide 1 should show/hide if Option A, Option B or Option C is chosen my old code fails.
My code works with one condition i.e.

if($values["make"] =="Option A")


However I have tried to reference the multiple options in the events on my before record updated event and the Before display event with no luck.
Have been trying some of the following options but all fail...

if($values["make"] == 'Option A' || 'Option B' || 'Option C')


if($values["make"] == 'Option A' or 'Option B' or 'Option C')


if($values["make"] =="Option A" or $values["make"] =="Option B" or $values["make"] =="Option C")


if($values["make"] ==(in_array( array("Option A", "Option B", "Option C"))))


How can I deal with the multiple choices/ in Show/hide 1?
Any ideas much appreciated.
Many thanks,

J

woodey2002 author 8/25/2020

Figured it out!
This seemed twork for me.

if($values["make"] == 'Option A' || $values["make"] == 'Option B' || $values["make"] == 'Option C' )