Countdown Timer Question

Discussion in 'Javascript' started by Papajo, Feb 12, 2006.

  1. Papajo

    Papajo Guest

    This timer counts down from 5 and stops at 0, is there anyway to loop it
    so it will start the count down again? plus could the amount of times it
    loops be set?
           Thank you, Joe

    http://web2jo.com/Work/Timer.html
     
    Papajo, Feb 12, 2006
    #1
    1. Advertising

  2. Papajo wrote:
    > This timer counts down from 5 and stops at 0, is there anyway to loop
    > it so it will start the count down again? plus could the amount of
    > times it loops be set?
    > Thank you, Joe
    >


    var iCountStart = 5;
    var loopCountStart = 3;
    var iCount;
    var loopCount;
    var to;

    function startCountdown(start) {
    if (start) {
    if (to) {
    clearTimeout(to);
    }
    loopCount = loopCountStart;
    iCount = iCountStart;
    }
    if (loopCount > 0) {
    window.status = " "+iCount+" ";
    if (--iCount < 0) {
    loopCount--;
    iCount = iCountStart;
    }
    to = setTimeout('startCountdown(false)', 1000);
    }
    }


    <input type="button" onClick="startCountdown(true)" value="Start">


    JW
     
    Janwillem Borleffs, Feb 12, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Stewart

    GUI countdown timer in a JApplet?

    Ryan Stewart, Dec 23, 2003, in forum: Java
    Replies:
    2
    Views:
    911
  2. JSP countdown timer

    , Nov 1, 2005, in forum: Java
    Replies:
    4
    Views:
    14,865
  3. KennethGorelick

    Countdown Timer

    KennethGorelick, Feb 19, 2006, in forum: Python
    Replies:
    2
    Views:
    609
    KennethGorelick
    Feb 19, 2006
  4. Dirk Hagemann

    Countdown timer for different timezones

    Dirk Hagemann, Jul 6, 2006, in forum: Python
    Replies:
    1
    Views:
    484
    Marc 'BlackJack' Rintsch
    Jul 6, 2006
  5. Michael J.

    Need special kind of countdown timer

    Michael J., Aug 27, 2003, in forum: Javascript
    Replies:
    0
    Views:
    128
    Michael J.
    Aug 27, 2003
Loading...

Share This Page