Jump to content

JavaScript counter


houssam_ballout

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...