if/else
teste.asp
<form action="resultado.asp">
1) Pergunta
<input type="radio" name="h1" value="sim"> Sim <input type="radio" name="h1" value="nao"> Não<br><br>
2) Pergunta
<input type="radio" name="h2" value="sim"> Sim <input type="radio" name="h2" value="nao"> Não<br><br>
3) Pergunta
<input type="radio" name="h3" value="sim"> Sim <input type="radio" name="h3" value="nao"> Não<br><br>
4) Pergunta
<input type="radio" name="h4" value="sim"> Sim <input type="radio" name="h4" value="nao"> Não<br><br>
5) Pergunta
<input type="radio" name="h5" value="sim"> Sim <input type="radio" name="h5" value="nao"> Não<br><br>
6) Pergunta
<input type="radio" name="h6" value="sim"> Sim <input type="radio" name="h6" value="nao"> Não<br><br>
7) Pergunta
<input type="radio" name="h7" value="sim"> Sim <input type="radio" name="h7" value="nao"> Não<br><br>
8) Pergunta
<input type="radio" name="h8" value="sim"> Sim <input type="radio" name="h8" value="nao"> Não<br><br>
9) Pergunta
<input type="radio" name="h9" value="sim"> Sim <input type="radio" name="h9" value="nao"> Não<br><br>
10) Pergunta
<input type="radio" name="h10" value="sim"> Sim <input type="radio" name="h10" value="nao"> Não<br><br>
<input type="submit" value="VER RESULTADO" style="width:140px; font-family:Verdana; font-size:10px; color:#ffffff; border:0px; background-color:#a4a5a6; padding-bottom:1px;">
</form>resultado.asp
<%
h1 = request.Form("h1")
h2 = request.Form("h2")
h3 = request.Form("h3")
h4 = request.Form("h4")
h5 = request.Form("h5")
h6 = request.Form("h6")
h7 = request.Form("h7")
h8 = request.Form("h8")
h9 = request.Form("h9")
h10 = request.Form("h10")
total = 0
if h1 = "sim" then
total = total +1
end if
if h2 = "sim" then
total = total +1
end if
if h3 = "sim" then
total = total +1
end if
if h4 = "sim" then
total = total +1
end if
if h5 = "sim" then
total = total +1
end if
if h6 = "sim" then
total = total +1
end if
if h7 = "sim" then
total = total +1
end if
if h8 = "sim" then
total = total +1
end if
if h9 = "sim" then
total = total +1
end if
if h10 = "sim" then
total = total +1
end if
if total >= 3 then
response.write "Sim!"
else
response.write "Não!"
end if
%>
Mesmo com 10 respostas SIM ele dá o resultado de NÃO.
Qual foi meu erro e como consertar?
Obrigado.
Discussão (3)
Carregando comentários...