I currently have a string which is retrieved from an element's data and stored in the variable "s".
I want to set an onclick of a button using this string variable as the function name followed by "(this)" so for example if the string stored in s is "showText" the function would be "showText(this)"
At the moment I apply the onclick to my button like this:-
however it needs to be something along these lines to accept a string as the function name:-Code:b.onclick=function(){showText(this)};
Is this possible preferably without evalCode:b.onclick=function(){<S GOES HERE>(this)};


Reply With Quote
Bookmarks