• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Aug 04, 2020 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.

 

TOPICS
General troubleshooting , PDF forms

Views

2.0K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 04, 2020 Aug 04, 2020

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

Votes

Translate

Translate
Community Expert ,
Aug 04, 2020 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"?

Votes

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
community guidelines
Community Beginner ,
Aug 04, 2020 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??

Votes

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
community guidelines
Community Expert ,
Aug 04, 2020 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.

Votes

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
community guidelines
Community Beginner ,
Aug 04, 2020 Aug 04, 2020

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Beginner ,
Aug 04, 2020 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

Votes

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
community guidelines
Community Expert ,
Aug 04, 2020 Aug 04, 2020

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Community Beginner ,
Aug 04, 2020 Aug 04, 2020

Copy link to clipboard

Copied

no space Text52

Votes

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
community guidelines
Community Expert ,
Aug 04, 2020 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.

Votes

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
community guidelines
Community Beginner ,
Aug 04, 2020 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"?

Votes

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
community guidelines
Community Expert ,
Aug 04, 2020 Aug 04, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines