Skip to main content
cmmm55401215
Participant
April 15, 2019
Answered

percentage

  • April 15, 2019
  • 1 reply
  • 707 views

I do not know Javascript and need emergency help with this calculation please. I would be so grateful if anyone with knowledge could assist. I need to create several percentage calculations in Acrobat Pro DC. I know where to put it just need to code. It looks something like this:

AP to 30 (expressed as $) / % of Total

AP 31-60 (expressed as $) / % of Total

AP 61-90 (expressed as $) / % of Total

AP Over 90 (expressed as $) $ / % of Total

TOTAL (of AP above)

I need to know how to calculate to totals. There will be 4 separate scripts.

Thanks for any help!!!

This topic has been closed for replies.
Correct answer try67

Set the Format setting of the field to Percentage.

1 reply

try67
Community Expert
Community Expert
April 15, 2019

You can use something like this as the custom calculation script of your fields:

var v1 = Number(this.getField("AP to 30").valueAsString);

var v2 = Number(this.getField("Total").valueAsString);

if (v2==0) event.value = "";

else event.value = v1/v2;

cmmm55401215
Participant
April 15, 2019

Almost there thank you! The calculation is showing a % as a decimal, not as a whole number - like this:

AP to 30 = $  100.00 / % of Total    0.25 %

AP 31-60 = $  100.00 / % of Total    0.25​ %

AP 61-90 = $  100.00 / % of Total    0.25​ %

AP Over 90 = $  100.00 $ / % of Total    0.25​ %

TOTAL = $  400.00

Do you know how to fix the decimal place to read 25%

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 15, 2019

Set the Format setting of the field to Percentage.