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

Acrobat Pro - If / Then Addition

New Here ,
Nov 14, 2022 Nov 14, 2022

Copy link to clipboard

Copied

Hello,

 

I don't know too much involving Javascript. I have done a couple small items but nothing past what you consider "beginner". I was wondering if someone could help me with what I have below:

 

I have 2 columns. Column 1 contains text boxes that are labeled as "TQ1" through "TQ10". Column 2 contains drop downs labeled "DN1" through "DN2". I have 2 more text boxes on the pdf labeled "TotalD" and "TotalN".  What I would like to do is this: If "D" is selected in the drop down and 8 is put as the value for "TQ", then I would like that value added to the "TotalD" box. If "N" is selected in the drop down and 8 is the value, the I would like that value added to the "TotalN" box. I'd like to be able to do this for all rows (1-10). The values entered into the "TQ" boxes would be added together and the total would be put into the "TotalD" or "TotalN" boxes depending on what option they choose in the drop downs.

 

Thank you in advance for your help! I hope I made everything clear enough to find a solution.

 

Thanks!

TOPICS
Edit and convert PDFs , How to , JavaScript , PDF forms

Views

555

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

Copy link to clipboard

Copied

LATEST

In one of the field as custom calculation script use this:

var d = 0;
var n = 0;
for( var i=1; i<=10; i++){
if(this.getField("TQ"+i).valueAsString == "8" && this.getField("DN"+i).valueAsString == "D")d+=8;
if(this.getField("TQ"+i).valueAsString == "8" && this.getField("DN"+i).valueAsString == "N")n+=8;}
this.getField("TotalD").value = d;
this.getField("TotalN").value = n;

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