Call javascript function which name is in variable

user769154 picture user769154 · Jul 29, 2011 · Viewed 17k times · Source

The problem is next: Assume that we have a select. Onchange event we need to call some function, but name of this function kept in variable. How to call this function ?

Answer

Raynos picture Raynos · Jul 29, 2011
window[name]()

You can call functions by name reference by selecting them as a property of window and executing them