Highlighted

Form with check boxes to hide unhide subforms

lanar37171111

14-12-2016

I have a form that I am creating in LiveCycle Designer that has multiple check boxes and other fields on page 1.  Page 2 has some standard conditions.  I also have hidden sub forms on page 3 and on, that I want to make visible based on what check boxes are checked.  Is this possible?

Replies

Highlighted

lateniteNC

14-12-2016

Yes, this is common functionality with a dynamic form.

I am assuming that the subforms on page 3 have been their presence set to "hidden." Thus, when we check the box (changing its raw value from 0 to 1), the subform will appear. You need a bit of code to change the property from hidden to visable.

The best way to do this is to place some code in the click event of the checkbox on page 1 that  you want to trigger the change in presence from hidden to visible. Using javascript the code would be:

if (this.rawValue == 0){

  xfa.resolveNode("Some_hidden_Subform_onP3").presence = "hidden";

}else{

  xfa.resolveNode("Some_hidden_Subform_onP3").presence = "visible";

}

This code simply says of the checkbox is unchecked, the subform stays hidden; if the value of the checkbox changes to checked (other values besides zero), the subform is now visible. Substitute the name of your subform for the name in ("  ").

Highlighted

lanar37171111

15-12-2016

This is the code that I have:1084791_pastedImage_0.png

My subform6 is on the second page at this time and is hidden.  However, when I select the check box, the subform does not change to visible.

I also tried the following code without any success:

if(this.rawValue == 1){

= "visible";

}else{

= "hidden";

}

Any ideas why it is not working?  I can share the file if that is easier.

Thank you!

Highlighted

_Bruce_Robertson

MVP

15-12-2016

Hi,

Are you getting any exceptions.  Do you have "when exception is thrown" set to break in Acrobat under Edit ... Preferences ... JavaScript.

If you field is on Page2, then I would expect the resolveNode reference to be "Page2.Subform6".  In the script editor you can generate the reference to your fields.  Place your cursor in the Script Editor where you want your reference to appear, then go back to the form and select the object while holding down the Ctrl key and the reference will inserted into your Script.

If you are still having problems, upload your form somewhere like DropBox or Google Docs, and post a link in this thread and we can have a look.

Regards

Bruce

Highlighted
Highlighted

_Bruce_Robertson

MVP

17-12-2016

Hi,

The reference to you field needs to be case-sensitive, so Page2.Subform6 not page2.subform6.

But I suspect you've been playing around with different options.  You also need to save you file as a "Adobe Dynamic XML form", which is one of the options on the save file dialog.  A static PDF doesn't allow changes to the layout.

Highlighted

lateniteNC

18-12-2016

See Bruce's comments above.

You had a couple issues on your form, primarily that the document was saved as a static, rather than dynamic form. Additionally, it is often helpful to name your fields so that you do not end up with two fields having the same name. I changed the name of some of your checkbox fields to address this concern. I saved your form as a dynamic form, then added two text fields on page 2 for testing purposes (Driveway - Residential and Patios). Finally, I put the code in the click, not the change event.

Now if you check either one of those two checkboxes, the text (technical specs) will appear on page two. Just repeat the process with the other checkboxes and load the required specs in separate textboxes on page two. I located both hidden textboxes at the top of the page as I assumed that not more than one text box at a time would not be checked. If so, you may have to position your textboxes.

You also had a problem with the radio button group at the bottom of the page, which must have mutually exclusive values (you had two buttons returning a value of 1.) I fixed this as well.

You can download the file at: Dropbox - Engineering Permit 11.17.16.pdf