View Full Version : Increasing number value script

08-12-2008, 02:42 PM

After scouring the internet, I am unable to find a script which I need and was wondering if anyone would be able to help me.

I'm looking for a script which displays a number value (money) for example 2,504,272.21 and this value then constantly increases by random small values of say 17, 1.23 etc.

Basically it is to visually show progressive jackpots on an online casino website.

Does anyone know how I could do this or where I could get a script from?

Any help would be appreciated.



Philip M
08-12-2008, 04:28 PM
Try this:-

<span id="count"></span>

<script type = "text/javascript">

var num = 2504272.21;
var tim = 0;

function makeNum() {
var randy = (Math.floor(Math.random()*2000)/100) + 3.13; // random amount between 3.13 and 23.13
num = ((num*1) + randy).toFixed(2);
num1 = addCommas(String(num));
document.getElementById('count').innerHTML = "&#163;" + num1;
tim = window.setTimeout("makeNum()", 1000); // update once per second

function addCommas(nStr) {
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1,$2');
return nStr;

function stopit() {



<input type = "button" value = "Click here to stop the counter" onclick = "stopit()">

"The nice thing about standards is that there are so many to choose from."

08-12-2008, 06:11 PM
Thank you very much!

This is perfect after a couple of tweaks!