Skip to main content
Known Participant
May 17, 2021
Question

java for calculations

  • May 17, 2021
  • 2 replies
  • 566 views

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

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
May 17, 2021

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

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Nesa Nurani
Community Expert
Community Expert
May 17, 2021

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);