how to use var value name as function name in JavaScript -


hi guys can use value function name in javascript? have functions same name input values such as:

var ta = $('li.ramin.active').attr("id"); var act = $('input[name="'+ta+'_acceptdeny"]:checked').val();   act(freq, meid);  // question 

in way have error "uncaught typeerror: act not function" yes know act not function want use var act value function name!! need know how can that? all

you can use window[act](freq, meid)

thanks justin niessner pointing out work if act defined in global scope. use eval, however, considered unsafe.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -