PDA

View Full Version : Countdown script not working...



Humper
09-12-2006, 05:18 PM
I got this code from http://www.java-scripts.net/javascripts/Countdown-Timer.phtml ... it looks like it works on there site but when I put it into mine it doesnt work.. nothing shows up in the disabled box?

I just want it to count down from 30 sec..

this is in a php file.. sorry if it looks messy

print "<br><br><br>You will be redirected in:";
print "<form name=\"counter\"><input type=\"text\" size=\"8\" disabled name=\"d2\"></form>";
print "<script>";
print "<!--";
print "//";
print " var milisec=0";
print " var seconds=30";
print " document.counter.d2.value='30'";
print " function display(){";
print " if (milisec<=0){";
print " milisec=9";
print " seconds-=1";
print " }";
print " if (seconds<=-1){";
print " milisec=0";
print " seconds+=1";
print " }";
print " else";
print " milisec-=1";
print " document.counter.d2.value=seconds+\".\"+milisec";
print " setTimeout(\"display()\",100)";
print "} ";
print "display()";
print "-->";
print "</script>";

shachi
09-12-2006, 05:47 PM
I think that you should use echo instead of print, not sure though.

Humper
09-12-2006, 05:50 PM
print and echo are basically the same when it come to printing the html in php... I guess I can try this.. but dont think it will help.. it prints the box out fine but just doesnt put the value in the textbox..