These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Need help caculating total "yes" check boxes checked

Tech264
Registered: Apr 4 2008
Posts: 111
Answered

I have a form where I have 6 questions with yes / no check boxes in a table and the last row /column has a total field. Each Yes box Binding name is CBYES1, CBYES2, CBYES3, etc..
 
so i'm wondering in my total field is this the appropriate calculation?
 
form1.Page1.Table1.Row1.CBYES1+ form1.Page1.Table1.Row1.CBYES2+ form1.Page1.Table1.Row1.CBYES3
 
Any help is appreciated.
 

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Are the check boxes in an exclusionary group with a No box?

What are the values of the check boxes when the "Yes" check box is selected?

George Kaiser

Tech264
Registered: Apr 4 2008
Posts: 111
No just 1 table with 3 columns. Question is in column 1, Yes check box in Column 2, No Checkbox in Column 3. So no they're not grouped together and the Yes value is 1.



gkaiseril wrote:
Are the check boxes in an exclusionary group with a No box?What are the values of the check boxes when the "Yes" check box is selected?
Tech264
Registered: Apr 4 2008
Posts: 111
I normally don't bump a thread but I still haven't found a solution to my question.

Any help is greatly appreciated.
sergey2511
Registered: Aug 1 2011
Posts: 9
Hey, don't thank me, cause it's Michael Frommer's code, which I found on this forum, just adapted for your needs (you would need to change either your fields name or edit the code).

var aName = xfa.resolveNodes("CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;
put that into calculate section of your counter field. choose javascript.
Tech264
Registered: Apr 4 2008
Posts: 111
Hi thanks Sergey for responding. I've tried your code on page 1 of the form I'm attaching and it didn't work. I'm not sure if it's because the checkboxes are within a table as you will see. You'll notice where it says total it just says zero. Technically if no yes boxes are checked I wouldn't want the zero to be there if possible.

https://acrobat.com/#d=WM1jmoHw7BRgWOqv3d4LTw
Tech264
Registered: Apr 4 2008
Posts: 111
I was able to get the first checkbox to count but not sure how to get the other 5. Here's the modified code.

var aName = xfa.resolveNodes("Page1.Table1.Row1.CheckBox1[*]");var nCount = 0;for (i=0; i
sergey2511
Registered: Aug 1 2011
Posts: 9
try putting your [*] mark in some more places :)
like Row1 (if it's repeatable)
Tech264
Registered: Apr 4 2008
Posts: 111
I tried putting Row[*] and it didn't work because it's not a repeatable row.

I tried this as well and nothing happened:

var aName = xfa.resolveNodes("Page1.Table1.Row1.CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;var aName = xfa.resolveNodes("Page1.Table1.Row3.CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;var aName = xfa.resolveNodes("Page1.Table1.Row5.CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;var aName = xfa.resolveNodes("Page1.Table1.Row7.CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;var aName = xfa.resolveNodes("Page1.Table1.Row9.CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;var aName = xfa.resolveNodes("Page1.Table1.Row11.CheckBox1[*]");var nCount = 0;for (i=0; i<aName.length; i++){if ((aName.item(i).rawValue == 1)){nCount++;}}nCount;
sergey2511
Registered: Aug 1 2011
Posts: 9
your doc is password protected, so can't see the structure. I'm sure there should be a correct way to describe fields in xfa.resolveNodes

maybe like var aName = xfa.resolveNodes("Page1.Table1.Row1.CheckBox1", "Page1.Table1.Row2.CheckBox1"...)
I'm not an expert in Java syntax, so being in your situation, I would just put all checkboxes in 1 subform and then write like this:

var aName = xfa.resolveNodes("Page1.Table1.NewSubform.CheckBox1[*]")

Tech264
Registered: Apr 4 2008
Posts: 111
Sorry, I truly forgot about the password. Here's the form without the password. I truly appreciate the help.

https://acrobat.com/#d=WM1jmoHw7BRgWOqv3d4LTw
sergey2511
Registered: Aug 1 2011
Posts: 9
Accepted Answer
You should change you Row names from Row1, Row2, RowN to just Row. Then your variable should look like this:

var aName = xfa.resolveNodes("Page1.Table1.Row[*].CheckBox1")
Tech264
Registered: Apr 4 2008
Posts: 111
Sergey thank you so much. I never thought you could rename rows like that for calculating purposes. You learn something new everyday. I'm going to try and figure out the rest from here on. Thank you for your guidance.