1
I’m trying to validate the answer marked on a form. The intention is to create a multiple choice question where if the marked item is correct it presents a response, if not, that presents another message. The right answer comes to me, but the wrong one doesn’t. What could be wrong? Thank you!
Javascript
resp_a = document.getElementById("01_a").checked = false;
resp_b = document.getElementById("01_b").checked = false;
resp_c = document.getElementById("01_c").checked = true;
resp_d = document.getElementById("01_d").checked = false;
resp_e = document.getElementById("01_e").checked = false;
switch(){
case resp_a:
document.getElementById("resp_01").innerHTML = "Você errou, tente novamente!";
break;
case resp_b:
document.getElementById("resp_01").innerHTML = "Você errou, tente novamente!";
break;
case resp_c:
document.getElementById("resp_01").innerHTML = "Você acertou!";
break;
case resp_d:
document.getElementById("resp_01").innerHTML = "Você errou, tente novamente!";
break;
case resp_e:
document.getElementById("resp_01").innerHTML = "Você errou, tente novamente!";
break;
}
Switch will not do because you have to check all the answers, when finding the first correct answer the switch will be finished.
– Marcos Souza