<script type="text/javascript">
var ms = 0; var state = 0;
function start()
{
state = 1;
then = new Date();
then.setTime(then.getTime() - ms);
}
function stop()
{
state = 0;
now = new Date();
ms = now.getTime() - then.getTime();
document.stpw.time.value = ms;
}
function display()
{
setTimeout("display();",1);
if(state == 1)
{
now = new Date();
ms = now.getTime() - then.getTime();
var t = ms/1000;
document.getElementById("time").innerHTML=t;
document.getElementById("times").value=t;
}
}
</script>
<html>
<body onload="display()">
<form action="time.php"method="GET">
<p onclick="JavaScript:start()">เริ่มเกมส์<p>
<p onclick="JavaScript:stop()">หยุดเวลา</p>
<p id="time"></p>
<input type="submit"name="sub1"value="1">
<input type="submit"name="sub2"value="2">
</body>
</form>
</html>