countdown script!

Discussion in 'Blogging' started by eskape2mx, Oct 30, 2012.

  1. eskape2mx

    eskape2mx Newbie

    Joined:
    Nov 15, 2009
    Messages:
    42
    Likes Received:
    5
    Hey guys,

    Does anyone know of a countdown html script? Basically all I want it to do is countdown from 500 to 0 and have text next to it. (Items remaining 499) Like that and then have it countdown to 0 and I also need it restart every time the page is loaded. Please help! I'm not really a tech guy so if I could just copy and past it where I need it on my blog that would be great. Thanks in advance!
     
  2. jake454

    jake454 Junior Member

    Joined:
    Jun 4, 2012
    Messages:
    145
    Likes Received:
    110
    Location:
    Canada
    Code:
    [COLOR=#00008B][FONT=Consolas]
    var[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] count[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]=[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]0[/FONT][/COLOR][COLOR=#000000][FONT=Consolas];//set the value in seconds to count down from[/FONT][/COLOR]
    [COLOR=#00008B]var[/COLOR] counter=setInterval(timer, [COLOR=#800000]1000[/COLOR]); [COLOR=gray]//1000 will  run it every 1 second[/COLOR][COLOR=#00008B]function[/COLOR] timer(){  count=count-[COLOR=#800000]1[/COLOR];  [COLOR=#00008B]if[/COLOR] (count <= [COLOR=#800000]0[/COLOR])  {     clearInterval(counter);     [COLOR=gray]//counter ended, do something here[/COLOR]     [COLOR=#00008B]return[/COLOR];  }document.getElementById([COLOR=#800000]"timer"[/COLOR]).innerHTML=count + [COLOR=#800000]" secs"[/COLOR];}Then in your html on page put [COLOR=#800000]<span[/COLOR] [COLOR=#FF0000]id[/COLOR]=[COLOR=#0000FF]"timer"[/COLOR][COLOR=#800000]></span>[/COLOR]
    
     
  3. cv4yt

    cv4yt Newbie

    Joined:
    Nov 2, 2012
    Messages:
    14
    Likes Received:
    1
    Thanks, could be helpful even for me