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

calculation and rounding

emalveaux
Registered: Mar 23 2007
Posts: 6

I am using the following script. I want to calculate the value in the weight field x .01 and I want it to round up. So I want the Epinephrine dose to calculate based on the weight based on 0.1 mg per kilogram. (65 kg x 0.1). When it calculates, if I type 65.5 or 60.3 in the weight field, my end result is very long number i.e., .1555555. I just need a whole number like .16 or .15. Can someone help?
 
var wt = this.getField("fld.Weight")
var dse = this.getField("Sch.Epinephrine.Dose.mg.1")
 
if (wt.value == 0 || wt.value == "") {
 
dse.hidden = true}
 
else {
 
dse.hidden = false
dse.value = Math.round(((wt.value*.01)))}

My Product Information:
Acrobat Pro 7.0.8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Set the formatting action for the field to truncate the result.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script