Saturday, March 26, 2011

html timer

<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;
var m=0;
function timedCount()
{
document.getElementById('txt').value=m+":"+c;
c=c+1;
if(c==59)
{
m++;
c=1;
}
if(m==2)
{
alert("your time is over");
}


t=setTimeout("timedCount()",1000);a
}

function doTimer()
{
if (!timer_is_on)
  {
  timer_is_on=1;
  timedCount();
  }
}
</script>
</head>

<body>
<form>
<input type="button" value="Start count!" onClick="doTimer()">
<input type="text" id="txt">
</form>
<p>Click on the button above. The input field will count forever, starting at 0.</p>
</body>
</html>

No comments:

Post a Comment