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. Advertisements

  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. Advertisements

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:
    1,091
  2. JSP countdown timer

    , Nov 1, 2005, in forum: Java
    Replies:
    4
    Views:
    15,450
  3. KennethGorelick

    Countdown Timer

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

    Countdown timer for different timezones

    Dirk Hagemann, Jul 6, 2006, in forum: Python
    Replies:
    1
    Views:
    625
    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:
    248
    Michael J.
    Aug 27, 2003
  6. Bonnett

    Countdown Timer problems

    Bonnett, Jan 14, 2004, in forum: Javascript
    Replies:
    3
    Views:
    425
    Dr John Stockton
    Jan 15, 2004
  7. Christine
    Replies:
    4
    Views:
    264
    Lasse Reichstein Nielsen
    Jul 28, 2004
  8. MC

    Page Session Countdown Timer

    MC, Mar 22, 2008, in forum: Javascript
    Replies:
    13
    Views:
    924
    Evertjan.
    Mar 23, 2008
Loading...