Count number of text field with data

New Here ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

I made this formula, but sometimes it counts and sometimes it doesn't

 

if (this.getField("UNO").value == "")
event.value = 0;
else event.value = 1;

 

The idea is to count every text field that has any data. Each text field, when entering any data, has a result of 1. If it is empty, it has a result of zero

Can somebody help me

TOPICS
PDF forms

Views

59

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

correct answers 1 Correct answer

Adobe Community Professional , Jul 20, 2022 Jul 20, 2022

You don't need "AUX" fields for that.

You can use this as custom calculation script of "Total" field:

var fields = ["One","Two","Three","Four"];
var total = 0;
for( var i in fields)
if(this.getField(fields[i]).valueAsString != "")total++;
event.value = total;

Where "One","Two","Three","Four" are the name of the fields, you can add more fields to it.

Likes

Translate

Translate
Adobe Community Professional ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Is the field "UNO" the parent field name of a group of children fields prefixed with the same name?

 

For example, "UNO.1",  "UNO.2",  "UNO.3", etc.

 

 

 

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
community guidelines
New Here ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

I have a document with several fields.
One, two, three etc

 

When you enter names of people in each field (one, two, three, etc.), in another auxiliary field the result is 1, in order to count how many cells have value. When the field has no name, return 0

Example
ONE =Peter1                    AUX1= 1
TWO= Peter2                   AUX2= 1
THREE= Pedro3              AUX3= 1
FOUR= Empty                 AUX4= 0

                                         Total 3 

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
community guidelines
Adobe Community Professional ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

You don't need "AUX" fields for that.

You can use this as custom calculation script of "Total" field:

var fields = ["One","Two","Three","Four"];
var total = 0;
for( var i in fields)
if(this.getField(fields[i]).valueAsString != "")total++;
event.value = total;

Where "One","Two","Three","Four" are the name of the fields, you can add more fields to it.

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
community guidelines
New Here ,
Jul 20, 2022 Jul 20, 2022

Copy link to clipboard

Copied

LATEST

Thank you very much, it worked fine

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
community guidelines
Adobe Community Professional ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Where does you use the script?

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