Count Total Number of Check Boxes

New Here ,
May 11, 2020

Copy link to clipboard

Copied

How do I get a total number of check boxes?

 

They are named:

Check Box 1.0 - 1.9

Check Box 2.0 - 2.9

Check Box 3.0 - 3.9

Check Box 4.0 - 4.9

Check Box 5.0 - 5.9

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

In that case you can use this code as the custom calculation script of the field where you want to show the result:

 

var total = 0;
for (var i=1; i<=5; i++) {
	var fields = this.getField("Check Box "+i).getArray();
	for (var j in fields) {
		if (fields[j].valueAsString!="Off") total++;
	}
}
event.value = total;
TOPICS
Acrobat SDK and JavaScript

Views

245

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Count Total Number of Check Boxes

New Here ,
May 11, 2020

Copy link to clipboard

Copied

How do I get a total number of check boxes?

 

They are named:

Check Box 1.0 - 1.9

Check Box 2.0 - 2.9

Check Box 3.0 - 3.9

Check Box 4.0 - 4.9

Check Box 5.0 - 5.9

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

In that case you can use this code as the custom calculation script of the field where you want to show the result:

 

var total = 0;
for (var i=1; i<=5; i++) {
	var fields = this.getField("Check Box "+i).getArray();
	for (var j in fields) {
		if (fields[j].valueAsString!="Off") total++;
	}
}
event.value = total;
TOPICS
Acrobat SDK and JavaScript

Views

246

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2020 0
Most Valuable Participant ,
May 11, 2020

Copy link to clipboard

Copied

I'm assuming you mean the ticked check-boxes... If not, the answer is 50.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 11, 2020 0
New Here ,
May 11, 2020

Copy link to clipboard

Copied

Yes, total number of ticked check-boxes.  Thank you 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 11, 2020 0
Most Valuable Participant ,
May 11, 2020

Copy link to clipboard

Copied

In that case you can use this code as the custom calculation script of the field where you want to show the result:

 

var total = 0;
for (var i=1; i<=5; i++) {
	var fields = this.getField("Check Box "+i).getArray();
	for (var j in fields) {
		if (fields[j].valueAsString!="Off") total++;
	}
}
event.value = total;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 11, 2020 0
New Here ,
May 11, 2020

Copy link to clipboard

Copied

Sorry - but any chance of dumbing that down for me ... I'm unsure of where that script needs to go for it to work?  I have a Total Boxes Checked line for the number to go - but unsure of how to apply that script to that total line.

 

Appreciate all your help! 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 11, 2020 0
try67 LATEST
Most Valuable Participant ,
May 11, 2020

Copy link to clipboard

Copied

Go to the Properties of the field, Calculate tab and put that code under the third option, "Custom calculation script".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 11, 2020 1