Good afternoon, I'm building a form with checkboxes that call a function
through onclick
<body>
<form name="questao1" method="post" onsubmit="sendToDB();">
<br><input type="checkbox" name="Q1[]" value="Enfermagem" onclick="getPontos(1)"> Garantir a saúde das pessoas
<br><input type="checkbox" name="Q1[]" value="Eletroeletronica" onclick="getPontos(2)"> Máquinas e instalações elétricas.
<br><br><input type="submit" value="Próximo" onclick="finalizar()">
</form>
</body>
To perform this function:
function getPontos(pontos){
efmg = 0;
eltelt = 0;
info = 0;
alm = 0;
pltc = 0;
log = 0;
adm = 0;
qmc = 0;
ma = 0;
if (pontos == 1){ efmg = efmg + 1; }
if (pontos == 2){ eltelt = eltelt +1; }
}
function finalizar(){
if(efmg>eltelt){alert('Enfermagem');}else{alert('Eletroeletronica');}
}
However, every time I call this function the values return to zero, and I need the value to hold for the next checkbox click. the problem is that if I do not assign the initial values to zero, the function does not work, and the end does not show any result. Can someone help me solve it? Thanks in advance :)