Highlighted

NaN showing up in cell where I would like it blank.

Community Beginner ,
Aug 04, 2020

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.

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Then remove the space from your code... Also, you should make sure the value of that field can be converted to a number.

TOPICS
General troubleshooting, PDF forms

Views

52

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

NaN showing up in cell where I would like it blank.

Community Beginner ,
Aug 04, 2020

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.

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Then remove the space from your code... Also, you should make sure the value of that field can be converted to a number.

TOPICS
General troubleshooting, PDF forms

Views

53

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 04, 2020 0
Engaged ,
Aug 04, 2020

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"?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Community Beginner ,
Aug 04, 2020

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??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Engaged ,
Aug 04, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Community Beginner ,
Aug 04, 2020

Copy link to clipboard

Copied

Thank you so much for helping. It is working!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Community Beginner ,
Aug 04, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Adobe Community Professional ,
Aug 04, 2020

Copy link to clipboard

Copied

Is the field name "Text 52" or "Text52"?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Community Beginner ,
Aug 04, 2020

Copy link to clipboard

Copied

no space Text52

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Most Valuable Participant ,
Aug 04, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 1
Community Beginner ,
Aug 04, 2020

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"?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
try67 LATEST
Most Valuable Participant ,
Aug 04, 2020

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".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0