Yes it does. Thanks. So if I'm inside an anonymous function, can I
still use window, or do I need to figure out a scope variable to where
I am and use that?
Walter
On Apr 14, 2010, at 4:33 PM, Pranav wrote:
Does this help?
<script type="text/javascript">
function foo(){
alert("Meow");
}
function bar(){
alert('Woof woof');
}
var x = 'foo';
window[x]();
window['bar']();
</script>
On Apr 14, 2:52 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
In PHP, there's this handy construct where you can use the value of a
variable as the name of a function, so when you call $foo() you would
call the real function bar() or baz(), depending on the value of $foo
in the current scope.
Is there an equivalent in JavaScript, and if so, what is it? I am
looking at taking the return of an Ajax callback and using it to
decide whether to add or remove a classname from an element.
Thanks in advance,
Walter
--
You received this message because you are subscribed to the Google
Groups "Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
.
To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en
.
--
You received this message because you are subscribed to the Google Groups "Prototype
& script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.