thanks ohgod for that, made my code cleaner, but still didn't solve the problem.
Actually I found out about eval() a native function method that does exactly what I was trying to do.
Heres my code if anyone was wondering:
PHP Code:
eval(a.innerHTM.strip()+'()')
also you have to use strip() (from the prototype framework) because IE adds an extra space to innerHTML when called.
Update: I found a way to do this without using eval() which is supposably slow, unsecured, and frowned upon using, and not used in object oriented languages- So it's just good practice I guess.
Heres the code:
PHP Code:
c=html.strip();
myCode = c+'()';
myFucn = new Function(myCode);
and then call
to run.
Note: Function is
capitalized.
Whole second half taken from
here.