Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
//THis is a java script code part please i am passing function with the for loop but i want pass j values take 2sec time interval

      for(var j=1; j<=n;j++)
        {

                setInterval(function(){calcRoute(ss,j); alert("time");},2000);
        //this one is call 24 time for each for loop
          }


        //my question is in for loop if j=1 set interval 2000 misec
                                        j=2 set interval 2000 misec
                                        j=3 set interval 2000 misec
                                        j=4 set interval 2000 misec
                                        .......................
                                        .......................
                                        ........................
                                        j=n set interval clear


please give this problem soluction
Posted
Updated 2-Jul-12 23:42pm
v2
Comments
_Zorro_ 3-Jul-12 8:43am    
I'm sorry but your question is unclear to me. I don't understand what you want to achieve.
Sanju TV 3-Jul-12 8:53am    
cant get your question

1 solution

JavaScript
for(var j=1; j<=n;j++)
{
  var intr;       
  if(j==1)
  {
    intr= 2000;
  }
  else if(j==2)
  {
    intr= 2000;
   }
   else if( j == n)
   {
     intr = nnn;
    }
  setInterval(function(){calcRoute(ss,j); alert("time");},intr);

}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900