L
libsfan01
Hi all! I have this javascript timer which counts down the number of
secs that i put in and then then redirects my page, what i want to know
is how to i modify the code so that i can input the number of seconds
and this creates a DISPLAY of the form MM:SS (minutes:seconds)? Which i
feel is more aesthetically pleasing to the intended users of the site.
Kind regards
Marc
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var start=new Date();
start=Date.parse(start)/1000;
var counts=100; //NUMBER OF SECONDS TO COUNTDOWN FROM
function CountDown(){
var now=new Date();
now=Date.parse(now)/1000;
var x=parseInt(counts-(now-start),10);
if(document.form1){document.form1.clock.value = x;}
if(x>0){
timerID=setTimeout("CountDown()", 100)
}else{
location.href="redirect.php"
}
}
window.setTimeout('CountDown()',100);
</script>
</HEAD>
<BODY>
<FORM NAME="form1">
You are being redirected in
<INPUT TYPE="text" NAME="clock" SIZE="5" VALUE="10">
seconds.
</FORM>
secs that i put in and then then redirects my page, what i want to know
is how to i modify the code so that i can input the number of seconds
and this creates a DISPLAY of the form MM:SS (minutes:seconds)? Which i
feel is more aesthetically pleasing to the intended users of the site.
Kind regards
Marc
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var start=new Date();
start=Date.parse(start)/1000;
var counts=100; //NUMBER OF SECONDS TO COUNTDOWN FROM
function CountDown(){
var now=new Date();
now=Date.parse(now)/1000;
var x=parseInt(counts-(now-start),10);
if(document.form1){document.form1.clock.value = x;}
if(x>0){
timerID=setTimeout("CountDown()", 100)
}else{
location.href="redirect.php"
}
}
window.setTimeout('CountDown()',100);
</script>
</HEAD>
<BODY>
<FORM NAME="form1">
You are being redirected in
<INPUT TYPE="text" NAME="clock" SIZE="5" VALUE="10">
seconds.
</FORM>