## Custom Calculation Formula Needed

Dec 28, 2018

Copied

I have 31 text boxes, one for each day of the month.  In each text box there are 5 or 6 different entries, such as P, T, AB, AT.  I want to create a field to total the P's and T's but not the AB's and AT's.  How do I do that?

Most Valuable Participant
| Most Valuable Participant

OK, then you can use this code as the custom calculation script of the total field:

`var total = 0;for (var i=1; i<=31; i++) {    var v = this.getField("Smith "+ i).valueAsString;    if (v=="P" || v=="T") total++;}event.value = total;`

Edit: Forgot to add a space after "Smith"...

TOPICS
Acrobat SDK and JavaScript

Views

118

Likes

Report

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

## Custom Calculation Formula Needed

Dec 28, 2018

Copied

I have 31 text boxes, one for each day of the month.  In each text box there are 5 or 6 different entries, such as P, T, AB, AT.  I want to create a field to total the P's and T's but not the AB's and AT's.  How do I do that?

Most Valuable Participant
| Most Valuable Participant

OK, then you can use this code as the custom calculation script of the total field:

`var total = 0;for (var i=1; i<=31; i++) {    var v = this.getField("Smith "+ i).valueAsString;    if (v=="P" || v=="T") total++;}event.value = total;`

Edit: Forgot to add a space after "Smith"...

TOPICS
Acrobat SDK and JavaScript

Views

119

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 28, 2018 0
4 Replies 4
Most Valuable Participant ,
Dec 28, 2018

Copied

What are the names of those fields?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 28, 2018 0
Dec 28, 2018

Copied

Smith 1 through Smith 31

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 28, 2018 0
Most Valuable Participant ,
Dec 29, 2018

Copied

OK, then you can use this code as the custom calculation script of the total field:

`var total = 0;for (var i=1; i<=31; i++) {    var v = this.getField("Smith "+ i).valueAsString;    if (v=="P" || v=="T") total++;}event.value = total;`

Edit: Forgot to add a space after "Smith"...

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 29, 2018 1
LATEST
Dec 29, 2018