SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    webality...dunno what it means bcp_2005's Avatar
    Join Date
    Jun 2002
    Location
    Huntsville Alabama
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Countdown in JS?

    How do you make a countdown in JS? like it counts down 5 4 3 2 1 0 in a form field. it's for a page redirect. so when the page loads it says:
    you will be redirected in "number" seconds

    i'm stumped so i hope somebody can help!
    [ metabahn ] : changing the course of the web.

  2. #2
    SitePoint Guru okrogius's Avatar
    Join Date
    Mar 2002
    Location
    US
    Posts
    622
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try search hotscripts.com. Something like was definetely made by someone already.

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this?

    function countdown(s)
    {
    mySpan.innerText = s + ' seconds left...';
    //mySpan = <span id="mySpan"></span> somewhere in the document
    s--;
    setTimeout('countdown('+s+')', 1000);
    if(s <= 0) //do whatever you want to do...
    }


Bookmarks

Posting Permissions

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