- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
You could do it by nesting functions. I'd make a script object to store the functions and then call them from there.
So you'd have a function to find the subforms, a function to target the fields, etc. Then when you've found your subform you call another function to go through the subform and do what you need to the fields.
I haven't tested it but I'm pretty sure with Radzmar's function you can target individual subforms, etc. For example the line that calls the the function below, hideSubs(xfa.form), could target specific form like hideSubs(form1.subform1.subform2).
This is very pseudocode-y, I haven't bothered changing the name of the function. The colourFields function would look kinda like the hideSubs function but target fields instead of subforms. I don't have time to figure it out right now but might be able to take a look at it this weekend.
function hideSubs(vNode) {
if (vNode.className === "subform") {
//name of subform you're targeting
if (vNode.name === "targetSub") {
//call function colourFields
colourFields(targetSub);
}
}
for (var i = 0; i < vNode.nodes.length; i += 1) {
hideSubs(vNode.nodes.item(i));
}
}
hideSubs(xfa.form);