Copy link to clipboard
Copied
I have 2 calculated fields [txtMM] and [CalcEATotal] that supply another calculated field [AVGTotal413] with their values from 0 to 10.
AVGTotal413 has a Simplified field notation of "txtMM/CalcEATotal*100" but I MUST ensure that it wont calculate if either [txtMM] and [CalcEATotal] are equal to 0. If either is a zero, acrobat will throw an error no matter what page in the document you are on.
While my VBA logic could probably solve this issue, my knowledge of Javascript is in it's infancy and I need help here.
Thank you in advance
That's not quite true. If the numerator is 0 the result will be zero. Only if the denominator is zero will that result in an invalid operation, the result of which (in JS) is Infinity, but that can't be displayed by a field with the Number format, hence the error.
To solve it you must use a script to check the value of the latter first, like this:
var v1 = Number(this.getField("txtMM").valueAsString);
var v2 = Number(this.getField("CalcEATotal").valueAsString);
if (v2==0) event.value = "";
else
...
Copy link to clipboard
Copied
That's not quite true. If the numerator is 0 the result will be zero. Only if the denominator is zero will that result in an invalid operation, the result of which (in JS) is Infinity, but that can't be displayed by a field with the Number format, hence the error.
To solve it you must use a script to check the value of the latter first, like this:
var v1 = Number(this.getField("txtMM").valueAsString);
var v2 = Number(this.getField("CalcEATotal").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/(v2*100);
Copy link to clipboard
Copied
try67...THIS WORKS PERFECTLY!!!
Thank you sooo very much!!
Fred