1
Good afternoon, I’m putting together a form with checkboxes that call a function
through the 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 be maintained for the click of the next checkbox. the problem, is that if I do not assign the initial values as zero, the function does not work, and the finish does not show any result. Can someone help me solve it? I thank you in advance :)
Ook, I did this, but it still doesn’t work, I believe the error is now in the part of php Xp:
– Rafa Zanezi
But you understood what was wrong ne? If you have more doubts in PHP, I recommend you create another topic.
– leofontes
Yes, thank you :)
– Rafa Zanezi
@Rafazanezi if this answer solved your initial question, mark it as a solution in the left corner.
– JuniorNunes