File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Reflection for js? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Reflection for js?" Watch "Reflection for js?" New topic

Reflection for js?

graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
Is there a way to pass in the name of a method and have javascript execute it?

Something like reflection.


write, revise, re-write, revise, again...<br />write, revise, re-write, revise, again...
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
There is the "eval (string)" method, which evaluates its argument as if it were JavaScript code.
[ May 24, 2006: Message edited by: Ulf Dittmer ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63533

Consider the following:

[Asking smart questions] [About Bear] [Books by Bear]
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
Thanks Ulf,

Worked like a charm!
I agree. Here's the link:
subject: Reflection for js?
jQuery in Action, 3rd edition