1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I Will Give +REP and Thanks for a Simple Text Counter

Discussion in 'BlackHat Lounge' started by blackmagiquellc, Apr 12, 2009.

  1. blackmagiquellc

    blackmagiquellc BANNED BANNED

    Joined:
    Oct 30, 2008
    Messages:
    752
    Likes Received:
    739
    I need a simple text counter that will count up by random increments (like when the page loads start at 1484 and every 3 seconds go up by 5 or 7 or 12 or 2, etc)

    Kind of like a countdown but count up with text on random strings

    Please post or PM me code and I will hook you up​
     
  2. callmelucid

    callmelucid Regular Member

    Joined:
    Feb 15, 2009
    Messages:
    487
    Likes Received:
    446
    cant you do something like:

    Code:
    x=Math.random(0,100)*10+random(0,10)
    while (x<=2000)
    {
    x=x+random(0,15)
    }
    ....
    
    i suck at coding but is this around what you wanted?
     
    • Thanks Thanks x 1
  3. blackmagiquellc

    blackmagiquellc BANNED BANNED

    Joined:
    Oct 30, 2008
    Messages:
    752
    Likes Received:
    739
    sort of. I'm looking for a full code to run. Thanks given though.
     
  4. neobyte

    neobyte Junior Member

    Joined:
    Sep 15, 2008
    Messages:
    122
    Likes Received:
    16
    Just send you a PM for the snippet. The concept of work.
     
  5. BlackMelvyn

    BlackMelvyn Regular Member

    Joined:
    Jul 8, 2008
    Messages:
    202
    Likes Received:
    272
    Home Page:
    Hi,
    here a snippet :)

    HTML:
    <span id="xcounter"></span>
    <script type="text/javascript">
    var c_start = 1484; // Change it to any figure
    function c_increment(){
    	var c_count = Math.round(Math.random() * 10);
    	var o_count = parseInt(document.getElementById('xcounter').innerHTML);
    	document.getElementById('xcounter').innerHTML = c_count + o_count;
    }
    window.onload = function(){
    	document.getElementById('xcounter').innerHTML = c_start;
    	setInterval('c_increment()', 1000);
    }
    </script>
     
    • Thanks Thanks x 1
  6. BalingDazzer

    BalingDazzer Regular Member

    Joined:
    Mar 5, 2009
    Messages:
    229
    Likes Received:
    116
    BlackMelvyn, works perfectly, thanks! :)

    I tried editing the code to make it count down, but couldn't get it to work. Mind sharing a code snippet that would? (Would be great to use for sales pages.)
     
  7. BlackMelvyn

    BlackMelvyn Regular Member

    Joined:
    Jul 8, 2008
    Messages:
    202
    Likes Received:
    272
    Home Page:
    Hi
    Glad this helps :)
    The following snippet does exactly the contrary of the previous one.
    HTML:
    <span id="xcounter"></span>
    <script type="text/javascript">
    var c_start = 1484; // Change it to any figure
    function c_increment(){
    	var c_count = Math.round(Math.random() * 10);
    	var o_count = parseInt(document.getElementById('xcounter').innerHTML);
    	document.getElementById('xcounter').innerHTML =  o_count - c_count;
    }
    window.onload = function(){
    	document.getElementById('xcounter').innerHTML = c_start;
    	setInterval('c_increment()', 1000);
    }
    </script>
     
    • Thanks Thanks x 1