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

Javascript: SUM IF for Adobe PDF Forms

Community Beginner ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

Javascript: SUM IF for Adobe PDF Forms

I am wondering if there is something like a SUM IF Function for adobe. Basically, I want the calculation to if Row1 Column 1 = I then add Row 1 Column 5 (and I would have this repeat to check all rows but that part is simple. I am just stuck on making a statement that will add another amount if that row's column has a particular field "I" 

 

 

(Edited by Adobe Employee/Moderator: Title & Topics)

TOPICS
How to , JavaScript , PDF forms

Views

1.3K

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 , Nov 19, 2022 Nov 19, 2022

You can use something like this:

 

var total = 0;
if (this.getField("Text1").valueAsString=="I") total+=Number(this.getField("Text2").valueAsString);
if (this.getField("Text3").valueAsString=="I") total+=Number(this.getField("Text4").valueAsString); // etc.
event.value = total;

Votes

Translate

Translate
Community Expert ,
Nov 19, 2022 Nov 19, 2022

Copy link to clipboard

Copied

You can use something like this:

 

var total = 0;
if (this.getField("Text1").valueAsString=="I") total+=Number(this.getField("Text2").valueAsString);
if (this.getField("Text3").valueAsString=="I") total+=Number(this.getField("Text4").valueAsString); // etc.
event.value = total;

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 Beginner ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

This was a great idea but for some reason it isn't working. I even tried editing it slightly but the value always remains at 0.

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 Beginner ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

TOTAL_ROW_1 is 1.00 so it should be seeingthat the first this.getfield matches the string and add the 1.00 from TOTAL_ROW_1 to the default 0 variable and appear as 1.00 but for some reason it isnt. 

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 Beginner ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

LATEST

You are a life saver it did work I just did not have the bottom line added.

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