Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-06-2007, 09:33 PM   PM User | #1
vanarebane
New to the CF scene

 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vanarebane is an unknown quantity at this point
setInterval trouble

Hello.
This is my first time using setInterval in javascript and this is making me crazy. The script only alerts "1" and then stops. The "1st JavaScript Editor" debugger said on the line where is if(i == 75) that there is error "Function not found"
Thanks.

Code:
<script type="text/javascript" language="javascript1.5">
var variable = setInterval(koer(0), 200);
	
function koer (i){
    i++;
    alert(i);
    
	if(i == 75)
    {
		clearInterval(variable);
	}
}
</script>
vanarebane is offline   Reply With Quote
Old 09-06-2007, 11:11 PM   PM User | #2
rwedge
Regular Coder

 
Join Date: Feb 2005
Posts: 679
Thanks: 0
Thanked 16 Times in 15 Posts
rwedge is on a distinguished road
Missing quotes around koer(0)
Code:
var variable = setInterval('koer(0)', 200);
but i will never be more than 0 or 1
rwedge is offline   Reply With Quote
Old 09-07-2007, 03:10 PM   PM User | #3
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Code:
<script type="text/javascript"
var ind=0, variable;
function koer (){
alert(ind);
if(ind == 75){
ind=0;
clearInterval(variable);
}
else{
ind++;
}
}
onload=function(){
variable=setInterval('koer()', 200);
}
</script>
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:27 AM.


Advertisement
Log in to turn off these ads.