CMS Development

Jlawal
トップ投稿者

Javascript "NaN" statistics

解決

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 いいね!
1件の承認済みベストアンサー
Kevin-C
解決策
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

Javascript "NaN" statistics

解決

@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

元の投稿で解決策を見る

4件の返信
Kevin-C
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

Javascript "NaN" statistics

解決

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
トップ投稿者

Javascript "NaN" statistics

解決

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 スマイリー とてもハッピー

0 いいね!
Kevin-C
解決策
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

Javascript "NaN" statistics

解決

@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
トップ投稿者

Javascript "NaN" statistics

解決

Thank you for your help with this @Kevin-C . That has worked perfectly! とってもうれしいネコ