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

Simple Calculation Javascript

Constance
Registered: Mar 17 2011
Posts: 13

Hi - I need help with a simple javascript calculation. I wrote this javascript:
 
var cons = this.getField("Text6.0")
var cons = this.getField("Text5.0")
if (plan.value != 0)
event.value = cons.value - plan.value / plan.value
else
event.value = ""
 
However, the calculation doesn't work right. For Example
 
105 - 100 / 100 should equal to .05%, however, the script comes out to 0.00%. Is there a better way to write a script so that the answer comes to .05%?
 
Thanks
Connie

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Where have you defined the variable 'plan'?

Check your calculation for the correct order of arithmetic operators execution.

George Kaiser

KeyboardWizard
Registered: May 14 2011
Posts: 1
You used 'cons' twice and as stated, have not defined or initialized variable 'plan'

I would also ensure the subtraction was done first by (cons.value - plan.value) / plan.value

Bruce