Ciao a tutti,
ho trovato quello che cercavo.
Posto lo script magari può essere utili a qualcuno... un countdown con start stop e reset.
Buona giornata
Giuseppe
codice:
var CCOUNT;
$(document).ready(function(){
$('#btnct').click(function(){
CCOUNT = $('#seconds').val();
cdreset();
});
});
var t, count;
function cddisplay(){
document.getElementById('timespan').innerHTML = count;
}
function countdown(){
// starts countdown
cddisplay();
if(count ===0){
// time is up
}else{
count--;
t = setTimeout(countdown,1000);
}
}
function cdpause(){
// pauses countdown
clearTimeout(t);
}
function cdreset(){
// resets countdown
cdpause();
count = CCOUNT;
cddisplay();
}
codice HTML:
<form id="frm">Seconds:
<input type="text" id="seconds" name="seconds" value="0" size="2" maxlength="2" />
<br/>
<input type="button" id="btnct" value="Input" />
</form>
<span id="timespan"></span>
<input type="button" value="Start" onclick="countdown()">
<input type="button" value="Stop" onclick="cdpause()">
<input type="button" value="Reset" onclick="cdreset()">