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

Custom Calculation Formula Needed

New Here ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

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?

TOPICS
Acrobat SDK and JavaScript

Views

411

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

Community Expert , Dec 29, 2018 Dec 29, 2018

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"...

Votes

Translate

Translate
Community Expert ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

Copied

What are the names of those fields?

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
New Here ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

Copied

Smith 1 through Smith 31

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
Community Expert ,
Dec 29, 2018 Dec 29, 2018

Copy link to clipboard

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"...

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
New Here ,
Dec 29, 2018 Dec 29, 2018

Copy link to clipboard

Copied

LATEST

That worked.  Thanks try67.  You are a rock star!!

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