Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Exit

- Home
- Acrobat
- Discussions
- How do I calculate Checked Check Boxes to equal a ...

- How do I calculate Checked Check Boxes to equal a ...

0

How do I calculate Checked Check Boxes to equal a Quantity?

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/td-p/9253486
Aug 19, 2017
Aug 19, 2017

Copy link to clipboard

Copied

Hello... stupid questions here, but I am creating a fillable form in a PDF a client sent me which was created in Excel. When the form is completed, the objective is to have a customer check a box for a size and/or multiple sizes which would equal a quantity. Once the quantity has been established it then needs to add or multiply the price per item and generate a total. I was able to get the quantity to multiple the price and get a total BUT I cannot figure out how to get the quantity to recognize its total based of the number of check boxes selected???

I tried to set it up where the value is the "product X" of the picked check boxes, but no luck???

Any help is appreciated and sorry if I have confused you! LOL!

TOPICS

PDF forms

Community guidelines

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

12
Replies
12

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/9253487#M63534
Aug 20, 2017
Aug 20, 2017

Copy link to clipboard

Copied

So basically you want to count the number of checked check-boxes and use it in your calculation?

If so, what are the names of the check-box fields you wish to count?

Community guidelines

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

Copy link to clipboard

Copied

Yes, thats basically it. There are 10 check-boxes and are named Check Box1 thru Check Box10. Thanks!

Community guidelines

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

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/9253489#M63536
Aug 21, 2017
Aug 21, 2017

Copy link to clipboard

Copied

You can use this code to count the number of checked boxes and apply use it as the value of a text field:

var total = 0;

for (var i=1; i<=10; i++) {

if (this.getField("Check Box"+i).value!="Off") {

total++;

}

}

event.value = total;

Community guidelines

les_sincavage
AUTHOR

Community Beginner
,

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/9253490#M63537
Aug 26, 2017
Aug 26, 2017

Copy link to clipboard

Copied

PERFECT! Thanks so much!

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/11600438#M286402
Nov 16, 2020
Nov 16, 2020

Copy link to clipboard

Copied

This code was extremely helpful! Thank you.

If you have a form with 2 sections, with the same check box fields, only I added an _ how could I calcualate the section section?

Example:

First section form check boxes labeled= Check Box1 - 10

Second section form check boxes labled= Check Box_1 - 7

Thank you in advance. š

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/12580671#M341364
Dec 08, 2021
Dec 08, 2021

Copy link to clipboard

Copied

So thus code is placed in the field I wish the total number to show up in?

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/12580772#M341373
Dec 08, 2021
Dec 08, 2021

Copy link to clipboard

Copied

Correct.

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/11534518#M282803
Oct 23, 2020
Oct 23, 2020

Copy link to clipboard

Copied

Hi there, was wondering if you could help me out on a similar issue. My issue is let's say I have a grid of 5 checkboxes by 5 checkboxes. and I want to total each row of checkboxes. The check boxes in row one are Check Box2_0 Check Box2_5 Check Box2_10 Check Box2_15 Check Box2_20

how would that script look? (as an aside, my numbers actually go 0-150 ... so if there is someway to code it for multiples of 5, where 150 is the largest, that would be helpful)

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/11534606#M282806
Oct 23, 2020
Oct 23, 2020

Copy link to clipboard

Copied

You just need to change the loop. For example, this will loop over fields 0, 5, 10, etc. up to 150:

for (var i=0; i<=150; i+=5) {

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/11541829#M283043
Oct 26, 2020
Oct 26, 2020

Copy link to clipboard

Copied

Oh thank you!!!!

Community guidelines

/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/13543896#M397191
Jan 31, 2023
Jan 31, 2023

Copy link to clipboard

Copied

Hey there, is it possible to help me with my issue? I have 11 questions with checkboxes, each checkbox has a value and I need to calculate all the checkboxes to Total. Checking out the attached file you will see only 2 of the questions. I use this code but it doesn't work for me:

var total = 0;

for (var i=1; i<=11; i++) {

if (this.getField("Check Box"+i).value!="Off") {

total++;

}

}

event.value = total;

It calculates each question as value 1, so finally I have 11 in the total section.

Thank you in advance!

Community guidelines

Community Expert
,

LATEST
/t5/acrobat-discussions/how-do-i-calculate-checked-check-boxes-to-equal-a-quantity/m-p/13543998#M397196
Jan 31, 2023
Jan 31, 2023

Copy link to clipboard

Copied

You should add the fields in Acrobat, first of all.

So what is the value for each box, then? Did you set it as the export value of each one?

If so, replace this line:

total++;

With:

total+=Number(this.getField("Check Box"+i).value);

Community guidelines

Resources

About Adobe Acrobat

Adobe Inc

Adobe Inc

Adobe Inc

Adobe Inc

Adobe Acrobat Feature & Workflow

FAQs

Copyright Ā© 2023 Adobe. All rights reserved.