houssam_ballout Posted December 12, 2006 Share Posted December 12, 2006 hello all, as I am new to JavaScript, I'd some small pages to finish, I want some script that will display the number of seconds down till 0 according to the number of second that I can give it via text boxthanks Link to comment Share on other sites More sharing options...
aspnetguy Posted December 12, 2006 Share Posted December 12, 2006 HTML <input type="text" id="secForCountDown"/> <input type="button" value="Start" onclick="start()"/><br/><br/><input type="text" id="countDown"/> JS var sec = null;function start(){ try { if(sec == null) sec = parseInt(document.getElementById('secForCountDown').value); sec--; if(sec > 0) setTimeout(start, 1000); } catch(err){ alert(err.description + '\n\nCount down failed!'); } } Something like that. I didn't test it so it may have errors Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now