Skip to main content
Participant
October 8, 2018
Answered

I want Acrobat to count the number of checkboxes which are selected in a form

  • October 8, 2018
  • 1 reply
  • 1653 views

I'm creating a form which will be used by certain proces checks. A number of questions will be launches which must be anwered by checkboxes whether it is good or not good. In case of the "not goods" the answers will be classified in different categories. I want acrobat to count all the "not goods" in the different categories. When i select a field and selct that field is calculated, I can select the checkboxes that needs to be calculated but there no output.... Can anyone help me?

This topic has been closed for replies.
Correct answer try67

The field where the sum has tot rak place is called "AantalRow1" and amon others the fields that should be calculated when they are selected (on) are for instance: "Check Box18", "Check Box19", "Check Box15", "Check Box16", "Check Box20". There will be more fields to becalculated when the form is complete but while designing the form I'd like to test it and see if it can be done! Do hope that you van provide the solution! Perhaps I should mail you the form so can take a look?


In this case you'll need to hard-code the names of the fields into the code.

Let's assume you want to count how many fields have the "ja" value selected.

You can use this code as the custom calculation script of the text field where you want to show the result:

var fields = ["Check Box18", "Check Box19", "Check Box15"]; // etc.

var total = 0;

for (var i in fields) {

    var f = this.getField(fields);

    if (f==null) {

        console.println("Error! Can't find: " + fields);

        continue;

    }

    if (f.valueAsString=="ja") total++;

}

event.value = total;

1 reply

try67
Community Expert
Community Expert
October 8, 2018

Do all of these fields have the same export values? If so, what are their names?

Participant
October 8, 2018

Yes, I have tried export value "1" and "ja" but both values did not give any result. In the destination field, the calculated field stil appears "0". If needed I can supply the form but it is not ready yet and I wanted to test it before finisch the whole form.

Inspiring
October 8, 2018

Since you have written and inserted some code, did you check the Acrobat JavaScript console to see if there are any errors?

Some errors will appear as a pop-up, others will only appear in the JavaScript console which you must manually open and check using the key combination of "<Ctrl> + J".

A common error is a misspelled field name.