<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<Html>
<Head>
<Title> New Document </title>
</Head>
<Body>
<Form action = "somepage. asp">
<Input type = "text" value = "0" name = "txt1"/>
<Input type = "button" value = "start" name = "btnStart"/>
<Input type = "button" value = "reset" name = "btnReset"/>
</Form>
</Body>
</Html>
<Script language = "JavaScript" type = "text/javascript">
<! --
// Obtain the form field in the form
Var txt = document. forms [0]. elements ["txt1"];
Var btnStart = document. forms [0]. elements ["btnStart"];
Var btnReset = document. forms [0]. elements ["btnReset"]
// Define the timer id
Var id;
// Increase the value by 1 every 10 milliseconds.
Var seed = 0;
BtnStart. onclick = function (){
// Determine the current operation based on the button text
If (this. value = "start "){
// Make the button text Stop
This. value = "stop ";
// Make the reset button unavailable
BtnReset. disabled = true;
// Set the timer to jump every 0.01 seconds
Id = window. setInterval (tip, 10 );
} Else {
// Change the button text to start
This. value = "start ";
// Make the reset button available
BtnReset. disabled = false;
// Cancel the timer
Window. clearInterval (id );
}
}
// Reset button
BtnReset. onclick = function (){
Seed = 0;
}
// Jump the stopwatch to a grid
Function tip (){
Seed ++;
Txt. value = seed/100;
}
// -->
</Script>