Tryit Editor v1.4

<html> <head> <script type="text/javascript"> var c=0; var t; function timedCount() { document.getElementById('txt').value=c; c=c+1; t=setTimeout("timedCount()",1000); } </script> </head> <body> <form> <input type="button" value="Start count!" onClick="timedCount()"> <input type="text" id="txt"> </form> <p>Click on the button above. The input field will count for ever, starting at 0.</p> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself