Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    Missing quotes around koer(0)
    Code:
    var variable = setInterval('koer(0)', 200);
    but i will never be more than 0 or 1

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •