Das ist das Javascript für einen Countdown. Da würde ich gerne noch den Rahmen und die Felder einfärben.
<script LANGUAGE="JavaScript">
<!--
var eventdate = new Date("enddatum");
function toSt(n) {
s=""
if(n<10) s+="0"
return s+n.toString();
}
function countdown() {
cl=document.clock;
d=new Date();
count=Math.floor((eventdate.getTime()-d.getTime())/1000);
if(count<=0)
{cl.days.value ="----";
cl.hours.value="--";
cl.mins.value="--";
cl.secs.value="--";
return;
}
cl.secs.value=toSt(count%60);
count=Math.floor(count/60);
cl.mins.value=toSt(count%60);
count=Math.floor(count/60);
cl.hours.value=toSt(count%24);
count=Math.floor(count/24);
cl.days.value=count;
setTimeout("countdown()",1000);
}
// Ende verstecken -->
</script>
<body onload="countdown()">
<form name="clock">
<table border=3>
<tr><td><center>Tage:</center></td>
<td><center>Stunden:</center></td>
<td><center>Minuten:</center></td>
<td><center>Sekunden:</center></td></tr>
<tr><td><center><input name="days" size="4"></center></td>
<td><center><input name="hours" size="2"></center></td>
<td><center><input name="mins" size="2"></center></td>
<td><center><input name="secs" size="2"></center></td></tr>
</table></form>
<script LANGUAGE="JavaScript">
<!--
var eventdate = new Date("enddatum");
function toSt(n) {
s=""
if(n<10) s+="0"
return s+n.toString();
}
function countdown() {
cl=document.clock;
d=new Date();
count=Math.floor((eventdate.getTime()-d.getTime())/1000);
if(count<=0)
{cl.days.value ="----";
cl.hours.value="--";
cl.mins.value="--";
cl.secs.value="--";
return;
}
cl.secs.value=toSt(count%60);
count=Math.floor(count/60);
cl.mins.value=toSt(count%60);
count=Math.floor(count/60);
cl.hours.value=toSt(count%24);
count=Math.floor(count/24);
cl.days.value=count;
setTimeout("countdown()",1000);
}
// Ende verstecken -->
</script>
<body onload="countdown()">
<form name="clock">
<table border=3>
<tr><td><center>Tage:</center></td>
<td><center>Stunden:</center></td>
<td><center>Minuten:</center></td>
<td><center>Sekunden:</center></td></tr>
<tr><td><center><input name="days" size="4"></center></td>
<td><center><input name="hours" size="2"></center></td>
<td><center><input name="mins" size="2"></center></td>
<td><center><input name="secs" size="2"></center></td></tr>
</table></form>
Logge dich ein um einen Beitrag zu schreiben.