Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Westicles-3niMA
Level 3
Level 3

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
dcidev
Correct answer by
Level 8
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
dcidev
Level 8
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

Westicles-3niMA
Level 3
Level 3

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.

dcidev
Level 8
Level 8

Are all the checkboxes under the same subform?

Kyle

dcidev
Level 8
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

Westicles-3niMA
Level 3
Level 3

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?

dcidev
Level 8
Level 8

Do all the top checkboxes end with _D ?

Kyle

dcidev
Correct answer by
Level 8
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

Westicles-3niMA
Level 3
Level 3

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

Cheers,

WES

Westicles-3niMA
Level 3
Level 3

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)

dcidev
Level 8
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

dcidev
Level 8
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

Westicles-3niMA
Level 3
Level 3

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?

dcidev
Level 8
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