• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

442

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
Community Expert ,
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);

Votes

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
Community Expert ,
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

Votes

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