Forum Moderators: open

Message Too Old, No Replies

Function name stored in variable

         

lobo235

9:15 pm on Jul 26, 2005 (gmt 0)

10+ Year Member



With javascript is it possible to store a function name in a variable and somehow invoke that function using the variable? I can do this in PHP but I'm not that familiar with javascript yet.

kaled

9:23 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think this will do what you want.

var test = "funcName";
eval(test + '()');

Kaled.

lobo235

9:24 pm on Jul 26, 2005 (gmt 0)

10+ Year Member



Great, that worked. Thanks a million!