Avatar

Level 10

Ok, finally had a chance to get to this...

function lockFields(vNode) {

          if (vNode.className === "field") {

                    vNode.access = "protected";

                    vNode.fillColor = "128,128,128";

          }

          for (var i = 0; i < vNode.nodes.length; i += 1) {

                    lockFields(vNode.nodes.item(i));

          }

}

function findSubs(vNode) {

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

        if (vNode.name === "targetSub") {

                              lockFields(vNode);

                    }

    }

    for (var i = 0; i < vNode.nodes.length; i += 1) {

        findSubs(vNode.nodes.item(i));

    }

}

findSubs(xfa.form);

You could abstract this to a Script Object by creating a Script Object and then copying and pasting the code in except for the "findSubs(xfa.form);" line at the end. Less code to maintain if you're using this in a lot of places. And then call it with:

myscriptobject.findSubs(xfa.form);