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 <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to