Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

would like you know how to loop this counter

Status
Not open for further replies.

mercifulrelease

Technical User
Joined
May 3, 2008
Messages
2
Location
GB
Hi,
I would like to know how to continuously loop this counter function. I have very little knowledge of scripts of any kind. Its part of an art project to have a continuous counter repeating itself. I discovered the counter which is extactly the right size and speed but i'm unable to make it start again from zero. Cheers

<script languge="JavaSript">
<!--
var count = 0;
function counter() {
document.timer.field.value = count++;
if (count != 6)
setTimeout('counter()',2000);
}
counter();
//--></script>
 
Try this:

Code:
if (count != 6) [!]{[/!]
   setTimeout('counter()', 2000);
[!]} else {
   count = 0;
   setTimeout('counter()', 2000);
}[/!]

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
[tt]function counter() {
document.timer.field.value = count++;
count=count%6;
setTimeout('counter()',2000);
}[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top