Copy link to clipboard
Copied
I have a fillable form with 3 columns. Daily Usage (Text51), Qty on Hand (Text52) and Estimated Days on Hand (Text53). So when they fill out their daily usage and quantity on hand it will autocalculate the estimated days on hand. Text52/Text51. Problem is it is autofilling NaN in Text53 cell. Because before they fill it out, there is Not a Number in there. I would like it to be blank or 0. Someone suggested this Javascript in "custom calculation script" but that isn't working.
var nDivisor = Number(this.getField("Text51").value);
if(nDivisor == 0)
event.value = "";
else
event.value = this.getField("Text 52").value/nDivisor;
Not sure how to proceed.
Then remove the space from your code... Also, you should make sure the value of that field can be converted to a number.
Copy link to clipboard
Copied
Are you trying to calculate "Text51"+"Text52" and show result in "Text53" and you want to "Text53" show nothing if there is no value in "Text51","Text52"?
Copy link to clipboard
Copied
var nDivisor = Number(this.getField("Text51").value);
if(nDivisor == 0)
event.value = "";
else
event.value = this.getField("Text52").value=nDivisor;
this is what I have in there. Thanks for calling out the space. I'm close now. Now it is just taking the number I enter in Text51 and putting it in Text53...not doing the calculation??
Copy link to clipboard
Copied
Return back .value=nDivisor; to .value/nDivisor; as you had before I was thinking you want something else sry about that.
Copy link to clipboard
Copied
Thank you so much for helping. It is working!!
Copy link to clipboard
Copied
I'm trying to calculate Text52/Text51 and show result in Text53 (division) and I want Text53 to show nothing if there is no value in "Text51, "Text52
Copy link to clipboard
Copied
Is the field name "Text 52" or "Text52"?
Copy link to clipboard
Copied
no space Text52
Copy link to clipboard
Copied
Then remove the space from your code... Also, you should make sure the value of that field can be converted to a number.
Copy link to clipboard
Copied
That was it. Thank you. Format of that field should be set to number? Not sure what you mean by "the value of that field can be converted to a number"?
Copy link to clipboard
Copied
The Format doesn't really matter. What matters is the actual value.
If the value of the field is "$12.00" then it won't work. If the value is "12.00" and the Format setting adds the currency symbol, then it will work, as it's not a part of the actual value.
It also won't work if you use a different number notation syntax, like "12,000.00", or "12.000,00".