Highlighted

How to calculate the number of checked checkboxes??

New Here ,
Jan 18, 2017

Copy link to clipboard

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
Correct answer by try67 | 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

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

How to calculate the number of checked checkboxes??

New Here ,
Jan 18, 2017

Copy link to clipboard

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
Correct answer by try67 | 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

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
Jan 18, 2017 0
Most Valuable Participant ,
Jan 19, 2017

Copy link to clipboard

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

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...
Jan 19, 2017 0
New Here ,
Jan 19, 2017

Copy link to clipboard

Copied

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

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...
Jan 19, 2017 0
Most Valuable Participant ,
Jan 20, 2017

Copy link to clipboard

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

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...
Jan 20, 2017 0
New Here ,
Jan 22, 2017

Copy link to clipboard

Copied

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

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...
Jan 22, 2017 0
Adobe Community Professional ,
Jan 22, 2017

Copy link to clipboard

Copied

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

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...
Jan 22, 2017 0
New Here ,
Jan 22, 2017

Copy link to clipboard

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

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...
Jan 22, 2017 0
New Here ,
Oct 26, 2020

Copy link to clipboard

Copied

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

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...
Oct 26, 2020 0