Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


java for calculations

New Here ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

i am trying to add fields "A" 'B" and Field "C" , they will  have numbers in them and display the total in another filed "K", unless that number is 0, and i also need the same thing but that total multiplied by Field "D" and displayed in ather field "L" if not 0 , i have tried built in calculations but they dont seem to update if  one of the first field is updated. thanks

TOPICS
How to, JavaScript, PDF forms

Views

254

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
community guidelines
Adobe Community Professional ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

Use this script in "K" field as custom calculation script:
var total = Number(this.getField("A").value)+Number(this.getField("B").value)+Number(this.getField("C").value);
if(total == 0)
event.value = "";
else event.value = total;


Use this script in "L" field as custom calculation script:
var total = Number(this.getField("A").value)+Number(this.getField("B").value)+Number(this.getField("C").value);
if(total == 0)
event.value = "";
else event.value = total*Number(this.getField("D").value);

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
community guidelines
Adobe Community Professional ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

LATEST

Sounds like a calculation order issue.  Look on the "More Menu" in the "Prepare Forms" Panel. You can set the calc order from there. 

 

CalcOrder.png

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines