Streaming live at 10am (PST)

Need some javascript magic


#1

Hi guys,

on my donation website I placed a ticker under the main navi, displaying the latest donations. The problem is, that the data I get, deliver the amount in cent instead of EURO. So if somebody donate 2 EURO the shown amount is 200. Is it possible to place a comma before the last two digits? I guess, that there exists some js magic to do this with every amount within that div, right? It would be a great help, if a js expert could solve this problem … i will pay a small fee via paypal.

http://spendenland.webflow.io/
https://preview.webflow.com/preview/spendenland?preview=c3c2591558e7e303a596457a25d01319

Thank you!


#2

Paste in Page Footer Code.

<script>
$('.amount').text(function(i,t) {
  return (parseFloat(t)/100).toFixed(2);
});
</script>

Also, feel free to contact me for further code help and/or customization of third-party plugins


#3

@samliew you are the best, thank you! Do you have an idea why the script places a dot instead of a comma? In Germany we write it this way: 2,00

I’ve found an hint and changed the code tho this:

<script>
  $('.amount').text(function(i,t) {
    return (parseFloat(t)/100).toFixed(2).replace(".", ",");
  });
</script>

It works but is it correct?


#4

Comma or period will depends on the users’ browser settings