If/Then Calculation - Can someone PLEASE help?

Jan 11, 2021

Copy link to clipboard

Copied

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.
TOPICS
Create PDF, How to

Views

21

Likes

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

If/Then Calculation - Can someone PLEASE help?

Jan 11, 2021

Copy link to clipboard

Copied

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.
TOPICS
Create PDF, How to

Views

22

Likes

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
Jan 11, 2021 0
Adobe Community Professional ,
Jan 12, 2021

Copy link to clipboard

Copied

Try the forum for Adobe Acrobat.

Likes

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
Reply
Loading...
Jan 12, 2021 0
try67 LATEST
Most Valuable Participant ,
Jan 13, 2021

Copy link to clipboard

Copied

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...

Likes

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
Reply
Loading...
Jan 13, 2021 0
Resources