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.
SOLVED

Can I have one check box that checks a suite of other check boxes?

Avatar

Former Community Member

I have a check box that is positioned above many other boxes on a sheet. I want that check box to serve as a "check all" by checking all the boxes beneath it when it is selected. I am sure there is a script for this but I am not familiar.

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 8

Try this:

var suffix=/(\w+_)D$/.exec(this.name)[1];

var i=1;

while (xfa.resolveNode(suffix+i)!=null){

          xfa.resolveNode(suffix+i).rawValue=this.rawValue;

          i++;

}

Kyle

View solution in original post

17 Replies

Avatar

Level 8

Try this:

for (var a=0;a<YourSubform.nodes.length;a++){

          vNode=YourSubform.nodes.item(a);

          if (vNode.className=="field" &&

                    vNode.ui.oneOfChild.className=="checkButton" &&

                    vNode.parent.className!="exclGroup"){

                    vNode.rawValue=this.rawValue;

          }

}

Where 'YourSubform' is the name of the subform with the checkboxes. Also, all On/Off values under the Binding tab must be the same.

Kyle

Avatar

Former Community Member

Can you include an image of the form that this was being used in? Not sure what is part of the script and what is unique to the form it was used in

Image for LiveCycle.png

This is how I want it to work where if any of the top boxes are checked, then the boxes directly beneath them will be checked as well. My binding names are ASSAY_D for the top "assay box" and ASSAY_1 beneath it and ASSAY_2 beneath that, etc.

Avatar

Level 8

Are all the checkboxes under the same subform?

Kyle

Avatar

Level 8

Put this in the change event (JavaScript) of all your 'Check All' boxes:

var suffix=/[^_]+/.exec(this.name);

var i=1;

while (xfa.resolveNode(suffix+"_"+i)!=null){

          xfa.resolveNode(suffix+"_"+i).rawValue=this.rawValue;

          i++;

}

Kyle

Avatar

Former Community Member

Cool that worked, kinda. I got the following result

Image for LiveCycle_2.png

So, as you can see, it worked for two full comlumns and almost a full column for the third. However, 3 of them did not work at all. the binding names for the ones that did not work are THN_SEC_1, THN_SEC_2, etc. I have a feeling that the underscore in the binding name messed it up. I can remove the underscores but I would prefer not to. Any other way?

Avatar

Level 8

Do all the top checkboxes end with _D ?

Kyle

Avatar

Correct answer by
Level 8

Try this:

var suffix=/(\w+_)D$/.exec(this.name)[1];

var i=1;

while (xfa.resolveNode(suffix+i)!=null){

          xfa.resolveNode(suffix+i).rawValue=this.rawValue;

          i++;

}

Kyle

Avatar

Former Community Member

It worked. Wow how can I thank you enough!? I am very thankful for your help, Kyle.

Cheers,

WES

Avatar

Former Community Member

What if I want to continue onto the next page with this script. As in...

Image for LiveCycle_3.png

Can I remove the "Check All"s from the second page and have the script from the first continue to these check boxes somehow? This is asking alot but you have been so helpful so far. They have continued suffix (as in page 1 ends with ASSAY_13 and page 2 starts with ASSAY_14)

Avatar

Level 8

Try this on for size:

var vNodes=this.parent.parent.resolveNodes('#subform[*].#field.(this.name.substr(0,this.name.length-1)=="'+this.name.substr(0,this.name.length-1)+'")');

for (var a=0;a<vNodes.length;a++)

          vNodes.item(a).rawValue=this.rawValue;

Kyle

Avatar

Level 8

Say Yes to the JavaScript

var vNodes=this.parent.parent.resolveNodes('#subform[*].#field.(this.name.indexOf("'+this.name.substr(0,this.name.length-1)+'")!=-1)');

for (var a=0;a<vNodes.length;a++)

          vNodes.item(a).rawValue=this.rawValue;

Kyle

Avatar

Former Community Member

I would also like to have one box that adds up the values of multiple boxes on multiple pages. The boxes to be added have the binding name INTVL_1, INTVL_2, INTVL_3, etc.

On a side note, where do you learn scripting like this?

Avatar

Level 8

Sorry, you've reached your daily limit ; )

In all seriousness though, start a new thread for the addition question.

You can learn about SOM predicates in the XFA Specification or

http://blogs.adobe.com/formfeed/2008/10/data_binding_with_predicates.html

Bruce BR001 really opened my eyes to the power of predicates with his search function http://forums.adobe.com/thread/518910

Kyle