Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Targeting all objects in multiple subforms with a shared name throughout a form

Avatar

Level 2
Level 2

Hi

Jono Moore was able to find an excellent solution from an original by Radzmar for targeting subforms throughout a form that share a name:

function hideSubs(vNode) {
     if (vNode.className === "subform") {
          //name of subform you're targeting
          if (vNode.name === "targetSub") {
               vNode.presence = "hidden";
          }
     }
     for (var i = 0; i < vNode.nodes.length; i += 1) {
          hideSubs(vNode.nodes.item(i));
     }
}
hideSubs(xfa.form);

Has anyone any thoughts on how to extend this functionality to select the object within those subforms?

So:     (1) find all subforms with the shared name (a solution above), then

          (2) select all objects inside those subforms only (all types: text fields, radio buttons, check boxes, etc.).

The intention is to lock these down and to apply a colour change (from white to grey) as a visual cue. The solution above allows the background colour of the subforms to be changed, but what is required in this case is a colour change to the value backgrounds of the objects within those subforms only.

Any thoughts grately appreciated.

Thanks

2 Replies

Avatar

Level 2

Please see the following sample which loops through all child elements in a subform.

I have it displaying the name of the objects.

https://workspaces.acrobat.com/?d=xuXORnYLNfXTNxUHukLJMw

Avatar

Level 10

Francis play around with the above code, it's a simplified version of the script you are using.

I've used that node traversal script for a bunch of stuff myself but I'm trying to wrap my head more around Radzmar's simplified version as it looks like it would be a lot faster for larger forms. And it's getting into areas I don't know much about so I'm learning stuff too!