Skip to main content
claires52602722
Inspiring
December 5, 2017
Answered

% Scripts in Acrobat pro fields

  • December 5, 2017
  • 2 replies
  • 1604 views

Hi Folks, I know nothing about scripts, but am trying to show a % in a field based on a total in 1 field minus a figure in a 2nd field = the % in the 3rd field. Anybody know if this is achievable?

This topic has been closed for replies.
Correct answer claires52602722

10 out of 534 is not 5.34%... It's 1.87%.


Apologies, I get it now.

Thank you for being patient with me.

I still do not understand coding (or math it seems!) - but this script has worked. I just need to paste it into the other cells on the form and adjust the target cells.

Thank you so much for your help with this - I am most grateful.

2 replies

claires52602722
Inspiring
December 6, 2017

Aah ok - how would I do that - as I said, this java stuff might as well be Klingon to me  

I really do appreciate you help.

try67
Community Expert
Community Expert
December 6, 2017

If I understand it correctly, it should be:

var a = Number(this.getField("DAY 17_2").value);

var b = Number(this.getField("27 32No of Chicks_2").value);

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

else event.value = (a/b);

claires52602722
Inspiring
December 6, 2017

Ok - that seems to work well with 100 or 1000 chicks, but doesn't seem to work with an uneven number (which it may well be).

Any suggestions?  

Figure should be 5.34% at the bottom?

claires52602722
Inspiring
December 5, 2017

Example:

My clients is sending 1000 newly hatched chicks via an airline

14 of these chicks die in transit

So I need the 3rd box to show 1.4%

Thom Parker
Community Expert
Community Expert
December 5, 2017

This is a standard formatting option.  Look on the Format tab of the field properties

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
claires52602722
Inspiring
December 6, 2017

Thank you Thom,

I have formatted the cell Percentage, what I am after is a script that will show (C) as a % of box (B) based on the total in box (A).

I actually need box (C) to show 2% in this example rather than 98%

try67