PDA

View Full Version : slowing down a loop



JAVAEOC
Nov 17th, 2003, 10:03 PM
how can i slow down a loop...
for example...

while(i<=100){document.write("hello")}

... this should write "hello" a 100 times, but how can i make it write each hello after the last one and not all at once?

i am thankfull for any help:D

A1ien51
Nov 17th, 2003, 10:07 PM
use setInterval instead of using loops.....

JAVAEOC
Nov 17th, 2003, 10:08 PM
mhhh.... ok .... ehhh... dunno what ur talkin about :o

well, ok... i use setInterval... but where and how?

A1ien51
Nov 17th, 2003, 10:13 PM
LEARN TO USE GOOGLE

Willy Duitt
Nov 17th, 2003, 10:13 PM
http://www.codingforums.com/search.php?s=&action=showresults&searchid=186323&sortby=lastpost&sortorder=descending

.....Willy

JAVAEOC
Nov 17th, 2003, 10:30 PM
still dont get it... it just gives me the number 23660984 and every time i refresh it it goes up one more :(

JAVAEOC
Nov 17th, 2003, 11:36 PM
please someone explain to me how to use setInterval

i cant figure it out...:mad:

please

P.S. google doesnt work
none of the webpages work for me
and none of the threads work

please help me

Danne
Nov 18th, 2003, 04:24 PM
From Netscapes reference:

Evaluates an expression or calls a function every time a specified number of milliseconds elapses, until canceled by a call to clearInterval.

setInterval(expression, msec)



Something like this ought to do it:



var counter = 0;
var interval=setInterval('if(counter<100){document.write("hello");counter++;}else{clearInterval(interval);}', 1000);

JAVAEOC
Nov 18th, 2003, 04:47 PM
YEPY... THANKS IT WORKS... :thumbsup:

THANKS, THANKS, THANKS :D