var seconds = 3600;Originariamente inviato da fcaldera
non c'è niente di utile da poter prendere nelle passate discussioni ?
function $(id) {
return document.getElementById(id);
}
function writecounter(hh, mm, ss) {
$('ore').value = (hh < 10)? "0"+hh : hh;
$('min').value = (mm < 10)? "0"+mm : mm;
$('sec').value = (ss < 10)? "0"+ss : ss;
}
function startcount() {
hh = Math.floor(seconds / 3600);
mm = Math.floor((seconds - (hh*3600)) / 60);
ss = seconds - (hh*3600) - (mm*60);
writecounter(hh, mm, ss);
seconds--;
if (seconds != -1) {
setTimeout('startcount()', 900)
}
else {
// fai qualcosa
alert("ho finito!");
}
}
var hh = Math.floor(seconds / 3600);
var mm = Math.floor((seconds - (hh*3600)) / 60);
var ss = seconds - (hh*3600) - (mm*60);
<FORM>
<input type="text" size="2" id="ore" /> :
<input type="text" size="2" id="min" /> :
<input type="text" size="2" id="sec" />
<input type="button" onclick="startcount()" value="start">
</FORM>
<script>
writecounter(hh, mm, ss);
</script>
Questo andrebbe bene (l'ho preso da una tua discussione)....ma io vorrei che il countdown partisse in automatico al caricamento della pagina....(senza pulsanti) come si fa????

Rispondi quotando