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

Calculation script runs every time I enter a value in any field

rbr00x
Registered: Oct 14 2009
Posts: 26

I am using the following script to multiply a value entered by the user times -1. It also changes a zero to a space.

// compute the discount amount based on the discount rate
event.value = this.getField("spouse_immediate_lifestyle").value * this.getField("negative_multiplier").value;
// suppress a zero result
if (event.value == 0) event.value = "";

I enter a value in cell one and it calculates properly, but when I enter a value in cell two, the negative in cell 1 changes to a positive. Then when I enter a value in cell 3, cell one changes back to negative and cell 2 (same script with modified field name) changes to positive, and so on...

How do I stop the calcuation from performing every time a new number is entered somewhere on the form?

Thanks for any insight!

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
This is the way the calculate action is triggered in Acrobat. More information about event triggering is contained in the freely downloadabe Acrobat JavaScript API Reference.

[url=http://www.adobe.com/devnet/acrobat/javascript.php]Acrboat JavaScript[/url]

George Kaiser

rbr00x
Registered: Oct 14 2009
Posts: 26
Thank you for the information.

I don't actually need the value to be stored as a negative number. What my end user wants is for the number that is entered to be formatted as negative currency(red and in parentheses). Could this be easily accomplished? The way they have it set up currently, they force you to type in the minus with the number. I don't think that is very user-friendly.

Thanks again for your help.
rbr00x
Registered: Oct 14 2009
Posts: 26
OK, I figured it out. I just added an "if" statement to check for >0//determine value
if (event.value > 0)//if n>0 multiply by -1
event.value = this.getField("FieldName1").value * this.getField("negative_multiplier").value;

// suppress a zero result
if (event.value == 0) event.value = "";


Thanks for the link.