1
I would like to know how to execute a Javascript function by taking its name in the database. Example:
data["nome_coluna"] // essa será a informação que estará no banco. (exemplo: somar();)
// Aí o objetivo é executar essa função dentro de um if.
if(data["nome_coluna"] != ""){
data["nome_coluna"];
}
Is there a way to do that? Is that way wrong? If so, how to do?
NOTE: The purpose of this is to make that when I buy a card and it has a function that must happen immediately, then call the function that is saved in the database. As there are many cards, it is not feasible to keep doing an if for each letter, since they are different functions.
Only the function name. I need to call it inside if, only it will call the letter function in specific.
– Trimander
Currently with parentheses. but this is quiet to change, if it works without.
– Trimander
Anyway you will have to have on the page the code of all functions.
– Sam
The code yes, but it is easier for me to call the function directly from the bank and do only one if, than to keep checking which card is and calling the function.
– Trimander
Try this, but only if the function name comes without the parentheses:
if(window[data["nome_coluna"]]){
 window[data["nome_coluna"]]();
}
– Sam
Man, it worked!!! Thank you very much, what this window does?
– Trimander
It takes the global variables.
– Sam