Start and Stop a Timer

[Total: 0    Average: 0/5]

This impliments a simple timer.

Body Code:

<form name=exf1>
<input type=button value="Start" onclick="startIt()">
<input type=button value="Stop" onclick="stopIt()">
<BR>
<input type=text name=delta value="<?>" onfocus=blur()>
</form>
<script>
var _startTime = 0;
var _stopTime  = 0;
var _deltaTime = 0;
function startIt() {
  _startTime = new Date();
}
function stopIt() {
  _stopTime = new Date();
  _deltaTime = _stopTime.getTime() - _startTime.getTime();
  document.exf1.delta.value = _deltaTime.toString() + " msecs";
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *