4
In javascript, how do I take the value of a string and use as a function call, save in the database which function to use in the onchange of an input, exe: validaData, validaCPF, diaUtil.
Example:
var func = "processaDados";
func("teste",2);
function processaDados(x,y){
alert(x);
}
I’ve seen it in php if I’m not mistaken.
This response deserves many positive votes for explaining very well how to solve the problem without resorting to
evil, say,eval.– Oralista de Sistemas
@Renan what’s wrong with Eval?
– Luiz Santos
@Luizsantos These can be an interesting readings: 1. Eval is either good or bad? 2. Javascript usage of Eval(): what are the pros and cons?
– Woss
@Luizsantos the first question indicated by Anderson has an answer from me.
– Oralista de Sistemas