javascript countdown clock
Posted
by
roi
on Stack Overflow
See other posts from Stack Overflow
or by roi
Published on 2011-01-03T12:26:01Z
Indexed on
2011/01/03
13:54 UTC
Read the original article
Hit count: 165
<script>
var interval;
var minutes = 1;
var seconds = 5;
window.onload = function() {
countdown('countdown');
}
function countdown(element) {
interval = setInterval(function() {
var el = document.getElementById(element);
if(seconds == 0) {
if(minutes == 0) {
el.innerHTML = "countdown's over!";
clearInterval(interval);
return;
} else {
minutes--;
seconds = 60;
}
}
if(minutes > 0) {
var minute_text = minutes + (minutes > 1 ? ' minutes' : ' minute');
} else {
var minute_text = '';
}
var second_text = seconds > 1 ? 'seconds' : 'second';
el.innerHTML = minute_text + ' ' + seconds + ' ' + second_text + ' remaining';
seconds--;
}, 1000);
}
</script>
this is a good countdown clock and i want to show the time in datalist how do i do it? like in this site www.1buy1.co.il
© Stack Overflow or respective owner