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

Javascript: SUM IF for Adobe PDF Forms

Community Beginner ,
Nov 18, 2022 Nov 18, 2022

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
1.6K
Translate
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
1 ACCEPTED SOLUTION
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;

View solution in original post

Translate
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 ,
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;
Translate
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

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.

Translate
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

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. 

Translate
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
LATEST

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

Translate
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