prova a copiare ed incollare questo
codice:<html> <head> <script> var seconds = 1000; 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 start() { 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('start()', 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); </script> </head> <body> <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="start()" value="start" </form> <script> writecounter(hh, mm, ss); </script> </body> </html>
cambia il numero di secondi con la variabile "seconds"

Rispondi quotando