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 == 8) {
currentElement.presence = "visible";
}
else {currentElement.presence = "hidden";
}
}
}
} // End of the function
Views
Replies
Total Likes
Usually "this" word refers to the current object where the code is getting executed. If you are calling this function from the Subform, then you need to pass "this" to the function as argument.
If you want to consider one level up, then you need to pass this.parent and so on..
Let me know if this helps or you need more help..
Thanks
Srini
Well, my first inclination was to try:
SegmentScripts.Indie(this);
on the subform that I want to disappear. This seems to only hide subforms UNDER it in the heirarchy and not it itself. So it works as long as I have subforms under it but if it's the lowest subform child in the heirarchy then it doesn't work.
Views
Replies
Total Likes
Ok I have a feeling the problem lies in my loop itself (as I said I adapted it from another use).
Is it due to how I'm defining the variable currentElement? I think it's referencing myParentObject.nodes
currentElement = allChildElements.item(i);
allChildElements = myParentObject.nodes;
Views
Replies
Total Likes
I found out what was causing the problem was my own misunderstanding of the loop variables. currentElement is designed to be the child of wherever the function is called from.
So I changed the if/then statement in the function to affect currentElement's parent:
if(currentElement.className === "subform") {
if (xfa.resolveNode("form1.Page1.Page1.#subform.institutiontype").rawVal ue == 8) {
currentElement.parent.presence = "visible";
}
else {currentElement.parent.presence = "hidden";
}
}
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies