Skip to main content
Participant
May 15, 2020
Answered

Help with an IF THEN Calculation in PDF Form

  • May 15, 2020
  • 1 reply
  • 467 views

I am trying to do an IF THEN Calculation in PDF Form.  This is beyond my expertise with PDF.  There are 3 fields.  A1, B1, C1.    If A1 is greater than B1, then calculate A1-B1 =C1. If A1 is less than B1 then C1 would equals 0.  For example.

A1 =24

B1 =20

C1=4

 

or

A1=19

B1 =20

C1= 0

 

Can anyone help with this?

 

Thank you

This topic has been closed for replies.
Correct answer try67

Use this:

 

var a1 = Number(this.getField("A1").valueAsString);
var b1 = Number(this.getField("B1").valueAsString);
if (a1>b1) event.value = a1-b1;
else event.value = 0;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 15, 2020

Use this:

 

var a1 = Number(this.getField("A1").valueAsString);
var b1 = Number(this.getField("B1").valueAsString);
if (a1>b1) event.value = a1-b1;
else event.value = 0;