#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    2
    Rep Power
    0

    Help with delayed countdown


    I'm new to js and program mostly in php. I am trying to do a delayed countdown (from 15 to 1) but it either hangs indefinately or does not display the count.

    This:
    PHP Code:

              
    var docount=15;
              do
              {
              
    document.write(docount+\"..<br>\");
              docount=docount - 1;
              } while (docount >0)
              document.write(\"<br> 
    $player2 forfeits!\");
              </script>"

    does what I want (ignore the '\', I"m calling the js with php) but without the delay. I'd like it to pause for one second after each count.

    Please help!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    UK
    Posts
    45
    Rep Power
    12
    I managed so I countdown.
    Put it in a function, called say tick()

    Put this at the end of your function
    window.setTimeout("tock();", 100);

    then outside of the function put:
    window.onload = tick;

    And best not to loop it, the imeout will do the looping.

    You should be able to figure it out from there, if you need more help I'll send you some more of the code.
  4. #3
  5. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    You might get more response in the html/javascript forum. This is a java forum and they actually have little to do with each other.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    2
    Rep Power
    0
    Ah, I see that one now. Thanks for pointing it out.

IMN logo majestic logo threadwatch logo seochat tools logo