You are viewing limited content. For full access, please sign in.

Question

Question

Set field value with javascript then use field rules to hide section

asked on January 22, 2018

Hi - This is similar to the question I asked here. Instead of hiding sections based on whether a user has selected an option on the form/step in the process - I'd like to use JavaScript to check mark a field and then use the Field Rules to hide a section if that check mark is checked. I got this idea from the Forms 303 session at the conference this year.

Below are screenshots of my process. The Javascript is working but the Field Rules' only work if I change the check mark after the form is loaded. Even though the form loads with the field checked per the Javascript the section is not being hidden per the Field Rules.

 

 

Assigned Task when opened:

0 0

Answer

SELECTED ANSWER
replied on January 23, 2018 Show version history

Cassandra,

Try adding .change() to the end of the code where you are checking the box. JavaScript changes do not always trigger field rules because they don't fire off the same events as user-initiated changes.

For example,

$('.section2 input').prop('checked',true).change();

Alternatively, if that still doesn't work you could try using .click() instead of directly setting the checked property, which should simulate user action and trigger the correct events.

1 0

Replies

replied on January 23, 2018

Both options worked - Thanks Jason!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.