• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Counting the x's in a column

New Here ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

I have a fillable form that has columns in it that I want to total.  If I use the number one in entering the fields, I can get them to add up no problem.  But my boss would prefer that the forms are filled with and X.

How do I get a column to count the number of X's that were entered for a specific column? I am using Acrobat DC

TOPICS
General troubleshooting , PDF forms

Views

372

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
community guidelines
Community Expert ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

LATEST

In an PDF form, there is no concept of columns (at least not unless you've created a naming convention that would make it easy to determine which fields are part of a column). 

 

You would need to loop over all fields in question and compare their content to what you are looking for and then increment a counter. If you are looking for fields to be filled with an X, that sounds like you are not really looking for a text field, but would be better served with a checkbox (you can make the checkbox use an "X" as the checked mark - you do this on the Options tab of the checkbox field properties and select "Cross"). 

 

If you are using checkboxes, the selected state is reported as "Yes", so you would use a something like this as the calculation script of the field that will report the number:

 

 

var allCheckBoxes = [ "Check Box1", "Check Box2", "Check Box3" ];
var cnt = 0;

for (var i=0; i<allCheckBoxes.length; i++) {
    var f = this.getField(allCheckBoxes[i]);
    if (f != null) {
        if (f.value == "Yes") {
            cnt++;
        }
    }
}
event.value = cnt;

 

 

If you want to keep your text fields, change the line that compares with "Yes" to a comparison with "X".  You will of course hav to change the list of fields to inspect at the top of the script. 

 

 

Votes

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
community guidelines