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

form field if statement not calculating

scottchr
Registered: Jul 30 2009
Posts: 5

I've wrestled with this problem for the last 3 hours. I know how to do basic form calculations in a PDF form but I've come to the conclusion that I know far too little about using javascript to calculate within a PDF form and am hoping some of you kind folks might help me out.

Here's the situation:
I have a field (balancedue) that is based on the values in 2 other fields (totalfees and totalrebate).

If totalfees is greater than total rebate I want it to subtract the totalrebate from the totalfees and put the value in the balancedue field.

If totalfees is less than the totalrebate I want it to put a zero in the balancedue field.

I created the following if statement as a custom calculation script in the balancedue field:
++++++++++++++++++++++++++++++++++++++++++++++

var tf = +getField("totalfees").value;
var tr = +getField("totalrebate").value;

if (tf < tr) {
event.value = 0;
}
else
{
event.value = tf - tr;
}

+++++++++++++++++++++++++++++++++++++++++++++++

The first time through, it calculates just fine after I enter the totalfees value and the totalrebate value. Then if I change the totalfees value OR the totalrebate value (as if I entered one of them incorrectly the first time) the balancedue doesn't recalculate. The only way it will recalculate is if I reenter the values in BOTH the totalfees and the totalrebate fields.

Can someone clue me in on why it won't recalculate unless both totalfees and totalrebate are both changed and how I might fix it?

Thanks in advance for any help. I appreciate it.

My Product Information:
Acrobat Pro 9.1.1, Windows
scottchr
Registered: Jul 30 2009
Posts: 5
Never mind everyone. I guess sleeping on it and taking a fresh look at it in the morning did the trick.

Thanks to acrobat expert gkaiseril's answer in another forum I figured it out. All I had to do was fix the calcuation order and it worked.