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

Custom Calculation Script

ham168
Registered: Oct 5 2007
Posts: 2

I am writing custom calucation script to calculate monthly loan payments. I am using:function Monthly(principal, years, apr)
{
rate = this.getField("apr").value / 12;
payments = this.getField("years").value * 12;
event.value=this.getField("principal").value * rate / (1 - (1 / Math.pow(1 + rate, payments)));
}
And it's not working... why?!

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Is this an AcroForm or XFA Form? Your code is for an AcroForm.
Are the fields named correctly?
Are there any reported errors?
Have you tested the function outside the calculation script?
There is no need to place this code in a fucntion. Just place the calculation code in the script.

You need to learn some debugging techniques. This article might help.

[url=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/]http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/[/url]

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