<html>
<script type="text/javascript">
var num_perguntas = 3; // Número total de perguntas
var sim = 0, total = 0;
var respostas = new Array(num_perguntas + 1);
function receber( pergunta, resposta )
{
if( respostas[pergunta] == undefined )
{
total++;
if( resposta == 1 ) sim++;
}
else if( resposta == 1 && respostas[pergunta] == 0 ) sim++;
else if( resposta == 0 && respostas[pergunta] == 1 ) sim--;
respostas[pergunta] = resposta;
}
function submeter()
{
if(total < num_perguntas) alert("Não respondeu a tudo!"); // Mensagem se não responder a tudo
else if( sim < 2) alert("Sim < 2, Total = " + sim); // Mensagem se o números de sims for menor que 2
else alert("Sim >= 2, Total = " + sim); // Mensagem caso contrário
}
</script>
Pergunta 1:
Sim<input type="radio" name="1" value="1" onclick="receber(this.name,this.value)"/>
Não<input type="radio" name="1" value="0" onclick="receber(this.name,this.value)"/>
</br></br>
Pergunta 2:
Sim<input type="radio" name="2" value="1" onclick="receber(this.name,this.value)"/>
Não<input type="radio" name="2" value="0" onclick="receber(this.name,this.value)"/>
</br></br>
Pergunta 3:
Sim<input type="radio" name="3" value="1" onclick="receber(this.name,this.value)"/>
Não<input type="radio" name="3" value="0" onclick="receber(this.name,this.value)"/>
</br></br>
<input type="submit" value="Submeter" onclick="submeter()"/>
</html>