Avatar

Level 4

Hi,

When calling a function that hides/shows subforms, I can only seem to progress up in the heirarchy to parent(s).

Here's how I call the function

SegmentScripts.Indie(this.parent);

The problem is that if I place the "call" on a subform I'm trying to hide, it will hide sibling subforms unecessarily.  If I place the call on an object within the subform, it erratically flows up several subform layers instead of its direct parent. 

Is there a way to place the call on the subform I want to hide itself, without having the function flow up to its parent?

For reference, here's the function itself (on a script object called SegmentScrips).

function Indie(myParentObject) {

           // Declare some variables

          var allChildElements;

          var intNumElements;

          var currentElement;

          var i;

          // Get all the child nodes of the parent element

          allChildElements = myParentObject.nodes;

          // Total number of elements in the object

          intNumElements = allChildElements.length;

          // Loop through all the child elements

          for (i=0; i<intNumElements; i++) {

                    currentElement = allChildElements.item(i);

                      if(currentElement.className === "subform") {     

                              if (xfa.resolveNode("form1.Page1.Page1.#subform.institutiontype").rawValue == :smiling_face_with_sunglasses: {

                              currentElement.presence = "visible";

                              }

                              else {currentElement.presence = "hidden";

                              }

                      }

                   

          }

} // End of the function