...

View Full Version : setInterval trouble



vanarebane
09-06-2007, 09:33 PM
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.


<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>

rwedge
09-06-2007, 11:11 PM
Missing quotes around koer(0)
var variable = setInterval('koer(0)', 200);
but i will never be more than 0 or 1

Kor
09-07-2007, 03:10 PM
<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum