Highlighted

## How to calculate the number of checked checkboxes??

New Here ,
Jan 18, 2017

Copied

I have 90 check boxes in a pdf form. I want to calculate the total number of check boxes being checked in the form and show the result automatically in the "total" field. How can I do that? I do not know about scripts. Please help. Thank you!

Most Valuable Participant
| Most Valuable Participant

Use this code as the custom calculation script of the "total" field:

`var total = 0;for (var i=1; i<=90; i++) {    if (this.getField("cb"+i).value!="Off") total++;}event.value = total;`
TOPICS
PDF forms, Windows

Views

3.4K

Likes

Report

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

## How to calculate the number of checked checkboxes??

New Here ,
Jan 18, 2017

Copied

I have 90 check boxes in a pdf form. I want to calculate the total number of check boxes being checked in the form and show the result automatically in the "total" field. How can I do that? I do not know about scripts. Please help. Thank you!

Most Valuable Participant
| Most Valuable Participant

Use this code as the custom calculation script of the "total" field:

`var total = 0;for (var i=1; i<=90; i++) {    if (this.getField("cb"+i).value!="Off") total++;}event.value = total;`
TOPICS
PDF forms, Windows

Views

3.4K

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 18, 2017 0
7 Replies 7
Most Valuable Participant ,
Jan 19, 2017

Copied

Use this code as the custom calculation script of the "total" field:

`var total = 0;for (var i=1; i<=90; i++) {    if (this.getField("cb"+i).value!="Off") total++;}event.value = total;`

Likes

Report

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

Copied

Sorry try67! I'm very stupid at JS. I've input the script and no result shown. Did I make it wrong?

Likes

Report

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

Copied

Did you enter it under the field's action, as I've described, or did you use the Edit All JavaScripts command? If the latter, you may have corrupted the file...

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 20, 2017 0
New Here ,
Jan 22, 2017

Copied

I've entered it under the field's action. But when I debug the script, it shows the following error.

Likes

Report

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

Copied

You are not using the correct field name to get the field objects. JavaScript is case sensative.

Likes

Report

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

Copied

Thank you try67!! I know the problem now..... As I have revised the file many times and it is corrupted as you said. I used the original file and enter the script again and it works!!

Thank you very much!!

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 22, 2017 0
LATEST
New Here ,
Oct 26, 2020

Copied

Hi all, is there a way to have the total box be blank rather than show a 0   when nothing is selected?

Likes

Report

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