Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Increasing number value script

    Hi,

    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.

    Thanks

    Raks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Try this:-

    Code:
    <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() {
    window.clearTimeout(tim);
    }
    
    makeNum();
    
    </script>
    
    <br><br><br>
    <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."
    Last edited by Philip M; 08-12-2008 at 04:39 PM. Reason: Add comments

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much!

    This is perfect after a couple of tweaks!

    Rakesh


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •