views:

3644

answers:

4

How to pass parameter while call a function using setInterval. viz. setInterval('funca(10,3)',500); is incorrect.

+6  A: 

You need to create an anonymous function so the actual function isn't executed right away.

setInterval( function() { funca(10,3); }, 500 );
tvanfosson
yep. silly me. I could have thought of that ! Thanks buddy
Rakesh
A: 

Add them as parameters to setInterval:

setInterval(funca,500,10,3);
Kev
This will not work on Internet Explorer.
Kev
Whaa?! Since when was that allowed? (serious question)
Crescent Fresh
Not sure. My source was: https://developer.mozilla.org/en/DOM/window.setInterval
Kev
+3  A: 

You can use an anonymous function;

setInterval(function() { funca(10,3); },500);
Simon
A: 

This is not exactly the same parameters as I read here: http://www.w3schools.com/jsref/met_win_setinterval.asp

I'm a bit confused ...

Jon Kleiser