Skip to main content
New Participant
August 20, 2017
Question

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

  • August 20, 2017
  • 2 replies
  • 6990 views

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!

This topic has been closed for replies.

2 replies

New Participant
January 31, 2023

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!

try67
Braniac
January 31, 2023

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);

try67
Braniac
August 20, 2017

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?

August 21, 2017

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

try67
Braniac
August 21, 2017

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;