Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   Timing event infinite loop (http://www.go4expert.com/forums/timing-event-infinite-loop-t18587/)

msn90 17Jul2009 17:18

Timing event infinite loop
 
hi guys,
This is my Timing event infinite loop with stop button javascript program. it is very useful for you.

program code

Code:

<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);
}

function stopCount()
{
clearTimeout(t);
}
</script>
</head>

<body>
<form>
<input type="button" value="Start count!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
</form>
<p>
Click on the "Start count!" button above to start the timer. The input field will count forever, starting at 0. Click on the "Stop count!" button to stop the counting.
</p>
</body>

</html>

:cuss:

naimish 18Jul2009 08:42

Re: Timing event infinite loop
 
Thanks for Sharing.

Hreno 18Jul2009 16:40

Re: Timing event infinite loop
 
That's Javascript, not Java.

This should go under Web Development.

shabbir 18Jul2009 17:19

Re: Timing event infinite loop
 
Moved.


All times are GMT +5.5. The time now is 16:21.