PHP expert |
|
Inderdaad. Je moet de variabelen u, m en s niet halen uit je getElementById. Hou die waarden bij in je variabelen.
var uren = 0;
var minuten = 0;
var seconden = 10;
function countdown()
{
setTimeout("timeleft()", 1000);
}
function timeleft()
{
seconden -= 1;
if(seconden < 0) {
seconden = 59;
minuten -= 1;
if(minuten < 0) {
minuten = 59;
uren -= 1;
if(uren < 0) {
alert("TRIIIIIIIIIIIIING");
return;
}
}
}
document.getElementById('sec').innerHTML = (seconden < 10) ? "0" + seconden : seconden;
document.getElementById('min').innerHTML = (minuten < 10) ? "0" + minuten : minuten;
document.getElementById('u').innerHTML = (uren < 10) ? "0" + uren : uren;
setTimeout("timeleft()", 1000);
}
var uren = 0; var minuten = 0; var seconden = 10; function countdown() { setTimeout("timeleft()", 1000); } function timeleft() { seconden -= 1; if(seconden < 0) { seconden = 59; minuten -= 1; if(minuten < 0) { minuten = 59; uren -= 1; if(uren < 0) { alert("TRIIIIIIIIIIIIING"); return; } } } document.getElementById('sec').innerHTML = (seconden < 10) ? "0" + seconden : seconden; document.getElementById('min').innerHTML = (minuten < 10) ? "0" + minuten : minuten; document.getElementById('u').innerHTML = (uren < 10) ? "0" + uren : uren; setTimeout("timeleft()", 1000); }
Zoiets dus. Zie je waar jij fout gaat? |