Add/Remove buttons not working properly on hidden Subforms | Community
Skip to main content
Level 2
December 11, 2024
Solved

Add/Remove buttons not working properly on hidden Subforms

  • December 11, 2024
  • 1 reply
  • 1670 views

I have this pdf form (attached) that has hidden subforms that appear when certain boxes are checked. I'm having issues with my Section C. subforms. I have add/remove row buttons, plus buttons that allow the user to rearrange the data within. As long as the subform is set to Visible, the add/remove buttons work. When it is hidden, the add row button does nothing and the remove row button will take away the only row visible (and it shouldn't do that).

 

I'm hoping someone can tell me what where I went wrong?

 

To make it easier for you: 

If you answer "No" to the first question in Section B, Section C2 will appear. 

 

 

If you check "a PMA based on Test and Computation" in Section A and answer "No" to the first question in Section B, Section C3 will appear. 

 

 

 

C2 and C3 are my hidden trouble makers. 

 

TYIA!

Best answer by radzmar

Replace the script in the Add button: This can't work because it's starts with "this", so the resolveNode() method starts searching a node relative to the buttons position in the node tree. But there's no object "page1" in its direct neighborhood, so nothing happens, when you click it. 

this.resolveNode('page1._SectionC3').addInstance(1); if (xfa.host.version < 😎 { xfa.form.recalculate(1); }

 

Use this instead:

_SectionC3.addInstance(1);

 

1 reply

radzmar
Level 10
December 15, 2024

Where are those add/remove buttons located? I don't see a problem with the ones in C1 and D1.

Mav_SAuthor
Level 2
December 16, 2024

There are no problems with C1 and D1, because they are visible.

 

The issue is in the hidden subforms.

 

To get to C2 you have to check "No" to the first question in Section B. 

 

To get to C3, you have to check "a PMA based on Test and Computation" in Section A; then check "No" to the first question in Section B. 

 

Also, both C2 and C3 will work properly if I set them to "Visible". Which makes me believe it has to do with something in how hidden things work.

radzmar
radzmarAccepted solution
Level 10
December 17, 2024

Replace the script in the Add button: This can't work because it's starts with "this", so the resolveNode() method starts searching a node relative to the buttons position in the node tree. But there's no object "page1" in its direct neighborhood, so nothing happens, when you click it. 

this.resolveNode('page1._SectionC3').addInstance(1); if (xfa.host.version < 😎 { xfa.form.recalculate(1); }

 

Use this instead:

_SectionC3.addInstance(1);