Forums

Display form sections based on a form field value

momentis 22 May, 2014
I am finding myself in need of some help, similar to this post I started last year:

http://www.chronoengine.com/forums/posts/f5/t88290/hide-show-form-fields-based-on-form-value-when-form-opens.html

I find myself needing to do something like this again. Here's what I have:

A form opens with a drop-down allowing a user to select "Yes" or "No". Depending on their answer, one of two sections in the form is displayed. One of these sections contains another "Yes/No" drop-down. If the user chooses "Yes" again, I need the form to display sections based on a form field. Each of the four sections is wrapped in a DIV with id, "travel1 - travel4". I have the following code, from last year, to display fields on form load:

window.addEvent('domready', function() {
  if ( $('var_trips').value == '1' ) {...


This works fine on form load, but when I try to load this JS after the code necessary to perform the above-mentioned show/hide, it does not work. Is there any way to change this code to accomplish what I need?

Thanks!!
Rick
momentis 23 May, 2014
1 Likes
I ended up getting this to work. Many thanks to laurentmartin from the post referenced above. It turns out that I had everything coded correctly, I was merely missing the correct number of closing brackets. 😶 😶
GreyHead 23 May, 2014
Hi Rick,

Good to see you solved this. I highly recommend a parsing editor to spot 'extra' or 'missing' brackets. I use Sublime Text 3 with SublimeLinter at the moment and it has saved my bacon many times just by copying and pasting my code into it so see what it spots.

Bob
momentis 23 May, 2014
Thanks for the pointer, Bob!
This topic is locked and no more replies can be posted.