Buy Now
Sign in

Hide or Show a Container based on a field value

tshirley , September 08 2017
T
tshirley
Hi,

I have a form with several containers (set as Sliders) and I want one of them to be shown and available based on whether a certain date is within 30 days of today. And hidden if not. This date is read in from a DB table - it isn't set in the form.

So I set up a hidden variable "dateclose" which I calculate to contain 1 if the date is less than 30 days from today, and 0 otherwise. This custom code is in the onload event after the data is read, and it is working.

Then I placed 2 events in the designer events section, one Show for "New Value = 1" on dateclose with the container selected, and one Hide for "New Value != 1 with the container selected.

No matter what value of dateclose I use, the container remains active and visible.

I am obviously doing something wrong but I can't see it. Any help gratefully received.

Cheers

Tim
GreyHead
Hi Tim,

Not sure exactly what is happening here. But if you want the 'events' to be set before the form loads rather than dynamic when the user changes something then I would use CSS to show hide the container. Extend your custom code to set the container display to 'block' or to 'none'.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
T
tshirley
Hi Bob,

Thanks - in the situation it probably isn't worth the complexity - a copy of the form for the two use cases is just as good.

Coffee on the way.

Cheers

Tim
GreyHead
Hi Tim,

Thank you, much appreciated.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much