CMS Development

Jlawal
Top Contributor

Javascript "NaN" statistics

SOLVE

Hi all 🙂

 

I'm working on this page. There is a blue banner above the 'Other opportunities' section that displays stats. In the page editor the stats display correctly (please see image below). I have updated this page a number of times but the first three stats don't display, showing "NaN" instead.

 

Page editor viewPage editor view

 

Any advise on this would be greatly appreciated.

 

Many thanks,

Jamila

0 Upvotes
1 Accepted solution
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Javascript "NaN" statistics

SOLVE

@JlawalGreat to hear!

 

You can updae the number using jQuery.

With that said there are a hundreds of jQuery solutions.

 

Here are some ideas to look into.

1) Updating the script that modifies the DOM element(displayed number) itself. Rather than "printing" the number it could print a string thst would include the commas. This would probably best replicate the animation you have currently.

 

2) Update the DOM element aftert the animation.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

View solution in original post

4 Replies 4
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

Javascript "NaN" statistics

SOLVE

Hey @Jlawal Interesting issue here!

 

NaN for the non-js user means "not a number".

So Somewhere between the editor and something is interfearing with the script.

 

Now this is just a guess, but if you enter the final numbers 20,012 or 75,085,670 into the editor without the commas does that change anything?

My thought here is that maybe there is an error when parsing the author input.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Jlawal
Top Contributor

Javascript "NaN" statistics

SOLVE

Hi @Kevin-C , thank you for your help!

 

I've removed the commas and the nan has disappeared. You were right! Do you know if there is anyway to add the commas back in in a way that doesn't affect anything? It looks a bit odd without the commas Smiley Very Happy

0 Upvotes
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Javascript "NaN" statistics

SOLVE

@JlawalGreat to hear!

 

You can updae the number using jQuery.

With that said there are a hundreds of jQuery solutions.

 

Here are some ideas to look into.

1) Updating the script that modifies the DOM element(displayed number) itself. Rather than "printing" the number it could print a string thst would include the commas. This would probably best replicate the animation you have currently.

 

2) Update the DOM element aftert the animation.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Jlawal
Top Contributor

Javascript "NaN" statistics

SOLVE

Thank you for your help with this @Kevin-C . That has worked perfectly! Cat Very Happy