Hi everyone
I’m fairly new to javascript. I’ve created a script (below) that will countdown to a certain date i specify. However I’m having problems making the page refresh every second. If anyone has any advice on how i can do this or any tips to make my script more efficient i’d be very grateful!
<script language=”javascript” type=”text/javascript”>
var d = new Date();
var future = new Date(“September 20, 2007 18:30:00”);
var occur = (future – d);
var countdown = new Date(occur);
var cdate = countdown.getDate();
var chours = addzero(countdown.getHours());
var cmins = addzero(countdown.getMinutes());
var csecs = addzero(countdown.getSeconds());
function addzero(i) {
if (i<10)
{i=”0″ + i}
return i
}
document.write(“The next game will be in <br/>”)
document.write(cdate + ” Days : <br/>”);
document.write(chours + ” Hours : <br/>”)
document.write(cmins + ” Minutes : <br/>”)
document.write(csecs + ” Seconds <br/>”);
</script>