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

Question

Question

Javascript Help > Expand only completed section after submission

asked on December 9, 2016

I'm having trouble making this work 

What does the javascript look like if I want Field12 (section collapsed by default) to automatically expand when Field19 (multi-checkbox field) has any box checked? 

Also, is there a shortcut to make this repeatable? (when Field24 is checked, expand Field15, when Field52 is checked, expand Field34, etc.)

Thank you so much for your help! 

0 0

Answer

SELECTED ANSWER
replied on December 13, 2016

Thanks again, Dave. :)

As luck would have it, my code ended up finally working! At your suggestion, I did create a copy of the form and when I realized the show/hide option wasn't what I wanted, I kept the copy and applied my JavaScript code to the second version and voila! It was either that or one pesky little semi-colon. ;-P

For reference, here's the code I used to expand a collapsed section if a particular (checkbox) field has one or more boxes checked.

$(document).ready(function () {
  if ($('#q19 input').is(':checked')) {
      $('#q1 .collapsible').click();
  }
});  

Thanks again!

1 0

Replies

replied on December 11, 2016 Show version history

Hi Sarah,

Just from the sounds of it you could use Field Rules.  Set it to "Show" field 12 "When any" "Field 19" "is not blank".

This could be done by copying the form and use the new form on the user task so only those parts you want show up.  

It would by default hide field 12 and open it up when field 19 has anything in it.  Without knowing your exact situation, this is an option that might work. 

 

0 0
replied on December 12, 2016

Hi Dave,

Thank you for taking the time to help me out! I apologize that in my frustration I forgot to explain what I'm trying to do.  My form is quite lengthy so it's broken down into 9 collapsed sections. When the form is submitted only one of the nine sections is completed.  What I'm trying to figure out is how to *expand* only that one section to the person who gets the submitted form so that they don't have to open all of the sections to know which one is completed.

I got really excited about your idea until I realized the show/hide feature doesn't work because it still doesn't "open" the collapsed section; it just shows the section in it's collapsed state.

Thank you again for your help!!

0 0
replied on December 12, 2016

Hi Sarah,

On your "copy", you can take out all the code that collapses each section.  That way every section is expanded.  Then go ahead and use the field rules to show the section when the conditions are correct.  Put in a rule to show the section if the rule applies.  :)

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

Sign in to reply to this post.