These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Form Calculations and Percentages

vinyldust
Registered: Apr 29 2009
Posts: 11

Hi all,

I've browsed the forum and had great luck in finding some help on making my form data work using javascript in the custom fields, however one problem has remained...

One of my text fields is asking the user to enter a %. (example, 50).

Below it, I have another field, which calculates the value of another field, and devides it, by this % field above.

I have the division working properly, but I need to tell the % field, to add "0." infront of it, for my math to work out and to truly find the percentage, not just divide the 2 numbers.

I don't want to waste space on the form telling users to actually input 0.50 for 50%

ie,

A= 100
B= 20% (for my code to calculate properly, it should then be read as 0.20)
C= Answer of A divided by B

Any thought would be greatly appreciated.

Cheers!

My Product Information:
Acrobat Standard 8.0, Windows
suewhitehead
Registered: Jun 3 2008
Posts: 232
Maybe you could change the javascript on the field this number is used in, instead of this field. Instead of using the value of the first field, write the script to use the value * .001.

More than one way to skin.....
vinyldust
Registered: Apr 29 2009
Posts: 11
Hi, Thanks Sue,

Here's the code I have :

var v1 = +getField("ReturnprofitGoal").value;
var v2 = +getField("AdvertisersProfitMargin").value;

event.value = (v2 !== 0) ? (v1 / v2) : "";

AdvertisersProfitMargin being the field that a user is supposed to enter a %.

So how/where would I add your proposed *.001 to this?

Thanks!
vinyldust
Registered: Apr 29 2009
Posts: 11
Hi,

So I figured out what to do with the .001, but 2 of my calculations are returning results with very long decimals.

Is there any way to truncate the decimals with the code I have above?

Thanks!