Skip to main content
Participant
January 12, 2021
Question

If/Then Calculation - Can someone PLEASE help?

  • January 12, 2021
  • 2 replies
  • 320 views
Who can help me with some easy Javascript for an Adobe form that I am creating?
 
I have FieldA, FieldB, FieldC and Total.
 
If FieldB is GREATER THAN FieldC then Total = FieldA + FieldC.
 
If FieldB is LESS THAN FieldC then Total = FieldA + FieldB.
This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
January 13, 2021

Use the following code as the custom calculation script of Total:

 

var a = Number(this.getField("FieldA").valueAsString);

var b = Number(this.getField("FieldB").valueAsString);

var c = Number(this.getField("FieldC").valueAsString);

if (b>c) event.value = a+c;

else event.value = a+b;

 

Edit: small mistake fixed in the code...

Bernd Alheit
Community Expert
Community Expert
January 12, 2021

Try the forum for Adobe Acrobat.