How to fix javascript countdown seconds bug

gate608

New Member
so I have this countdown timer I created, \[code\]<script type="text/javascript">var interval; var minutes = 12; var seconds = 32; window.onload = function() { countdown('countdown');}function countdown(element) { interval = setInterval(function() { var el = document.getElementById(element); if(seconds == 0) { if(minutes == 0) { minutes=7;seconds=47; } else { minutes--; seconds = 60; } } if(minutes > 0) { var minute_text = minutes + (minutes > 1 ? ':' : ':'); } else { var minute_text = ''; } var second_text = seconds > 1 ?'':''; el.innerHTML = minute_text + ''+seconds + ' '+second_text + ' remaining'; seconds--; }, 1000);}</script> \[/code\]The result works perfectly, but when the timer reaches digits below 10, (12:03, 12:05, etc.) it displays the seconds without a '0' in the front. (12:3 instead of 12:03)I tried fixing this, but it has brought me nowhere. Is it possible to somehow edit my script to fix this bug?
 
Back
Top