I have this countdown timer javascript with a built in delay function. I need to change it to be a countup timer with same sort of delay function. I with I knew how to probably post a question on here as this doesn't seem to accept anything to easily. Let see if this works...
<script type="text/javascript">
function pad(num, size) {
var s = num+"";
while (s.length < size)
s = "0" + s;
return s;
}
function initCountdown(){
setTimeout(function() {
current_wait++;
if(current_wait <= waits.length) {
var countdowns = document.getElementsByClassName('countdown');
for(var i = 0; i < countdowns.length; i++) {
var number = parseInt(countdowns[i].innerHTML);
number--;
countdowns[i].innerHTML = pad(number, 2);
}
initCountdown();
}
}, waits[current_wait] * 1000);
}
var initial_number = 7;
var waits = [4, 24, 55]; //ADD HERE AS MANY SECONDS AS YOU DESIRE.
var current_wait = 0;
var countdowns = document.getElementsByClassName('countdown');
for(var i = 0; i < countdowns.length; i++){
countdowns[i].innerHTML = pad(initial_number, 2);
}
initCountdown();
</script>