I have got a piece of code, that should countdown some number (in this example 1111) and write it into span id="timeframe". But it doesn't work, i dont know why. Can you tell me where is my mistake, please?
<script language="JavaScript">
<!--
var txt_minute = "Min";
var txt_second = "s";
var time_left = 1111;
var temp=timeleft;
houres = Math.floor(temp / 3600);
temp %= 3600;
minutes = Math.floor(temp / 60)";
temp %= 60;
seconds= temp;
function display()
{
time_left -= 1;
if (seconds <= 0) {
seconds = 59;
minutes -= 1;
} else {
seconds -= 1;
}
if (minutes <= 0){
minutes=59;
houres-=1;
}
if (time_left <= 0) {
seconds = 0;
}
if (time_left > 0) {
document.getElementById("timeframe").innerHTML = houres +" hours" + minutes + " " + txt_minute + " " + seconds + " " + txt_second;
} else {
window.location.reload();
}
setTimeout("display()",1000);
}
display();
//-->
</script>
Dateobject and a lower interval frequency. JavaScript timers aren't great for countdowns :-)