Sandbox/68: Difference between revisions
< Sandbox
Gerald Chi (talk | contribs) m Blanked the page |
Gerald Chi (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<script> | |||
var c=0; | |||
var t; | |||
var timer_is_on=0; | |||
function timedCount() | |||
{ | |||
document.getElementById('txt').value=c; | |||
c=c+1; | |||
t=setTimeout("timedCount()",1000); | |||
} | |||
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> |
Revision as of 20:49, 28 November 2013
<!DOCTYPE html> <html> <head> <script> var c=0; var t; var timer_is_on=0;
function timedCount() { document.getElementById('txt').value=c; c=c+1; t=setTimeout("timedCount()",1000); }
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>
Click on the button above. The input field will count forever, starting at 0.
</body> </html>