JavaScript Calculation: Value does not enter the format of a field?
Hi,
I have an adobe form in which I need to calculate a value's variance from a range. For example, if the range is $1,000.00 to $2,500.00, and the value is $3,000.00, I need it to return a variance of $500.00. If the value was $1,500.00, I need it to return a variance of $0.00 since it falls in the range. There may be occasions in which the range is $0.00 to $0.00, in which case any value would be a variance.
I have a built an adobe form with the following form fields:
1.) Low End of Range (Set to $ Format)
2.) High End of Range (Set to $ Format)
3.) Actual (Set to $ Format)
4.) Average (Set to $ Format, automatically generates the average based on the entry to "Actual" field)
5.) $ Variance (Set to $ Format, automatically calculates the $ variance of the average to the ranges defined in 1 and 2 above)
6.) % Variance (Set to % Format, to automatically valculate the % variance of the average to the ranges defined in 1 and 2 above)
The problem I am having is when the user enters the high range they recieve an error saying "The valued entered does not match the format of the field [% Variance]". It does not seem to be causing an error with the calculation; however, I would like to find a way to avoid the error from displaying.
I have the following custom JavaScript calculation in the % Variance field:
var Average = this.getField("Avg").value
var Low = this.getField("Low").value
var High = this.getField("High").value
var Variance = this.getField("Variance$").value
if (High== 0)
event.value = "";
else if(Average <= Low)
event.value = Variance / Low;
else if (Average >= High)
event.value = Variance / High;
I am pretty new to JavaScript, so I thank you in advance for your assistance!
