Colleagues.
I'm trying to put two functions inside the onchange, but the functions only work when I take one or the other.
onchange="soma(); alterar();"
How could I solve this?
Thank you!
Colleagues.
I'm trying to put two functions inside the onchange, but the functions only work when I take one or the other.
onchange="soma(); alterar();"
How could I solve this?
Thank you!
The best way would be to use .addEventListener
so
el.addEventListener('change', soma);
el.addEventListener('change', alterar);
Another option would be to pass a function that calls both:
onchange="processar();"
and
function processar(){
soma();
alterar();
}
If these two functions have common logic it was better to have one to call the other.
Another option is still to put all actions separated by commas for the JavaScript to execute all:
onchange="(soma(), alterar());"
Example:
Clica aqui:
<input type="checkbox" onChange="(alert(1), alert(2));">