CMS Development

Jlawal
Contributeur de premier rang

Javascript "NaN" statistics

Résolue

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 Votes
1 Solution acceptée
Kevin-C
Solution
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Javascript "NaN" statistics

Résolue

@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

Voir la solution dans l'envoi d'origine

4 Réponses
Kevin-C
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Javascript "NaN" statistics

Résolue

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
Contributeur de premier rang

Javascript "NaN" statistics

Résolue

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 très heureux

0 Votes
Kevin-C
Solution
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Javascript "NaN" statistics

Résolue

@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
Contributeur de premier rang

Javascript "NaN" statistics

Résolue

Thank you for your help with this @Kevin-C . That has worked perfectly! Chat très heureux