Buenas,
Estoy creando un test pero cuando le doy al botón CORREGIR, no me hace nada. ¿Alguien ve algún error?
Código Javascript
:
Ver original<html>
<head>
<title>Corrección de un test</title>
<script language="JavaScript">
function corregir(){
var p1
var p2
var p3
var aciertos = 0
var fallos = 0
var blancos = 0
var nota
var notaFinal
<!-- 1º pregunta-->
if (document.getElementById('p11').checked==true) {
p1 = -0.5;
aciertos++;
}else if (document.getElementById('p12').checked==true){
p1 = -0.5;
fallos++;
}else if (document.getElementById('p13').checked==true){
p1 = 1;
fallos++;
}else if (document.getElementById('p14').checked==true){
p1 = -0.5;
fallos++;
}else{
p1= -0.1;
blancos++;
}
<!-- 2º pregunta-->
if (document.getElementById('p21').checked==true) {
p2 = -0.5;
aciertos++;
}else if (document.getElementById('p22').checked==true){
p2 = 1;
fallos++;
}else if (document.getElementById('p23').checked==true){
p2 = -0.5;
fallos++;
}else if (document.getElementById('p24').checked==true){
p2 = -0.5;
fallos++;
}else{
p2= -0.1;
blancos++;
}
<!-- 3º pregunta-->
if (document.getElementById('p31').checked==true) {
p3 = -0.5;
aciertos++;
}else if (document.getElementById('p32').checked==true){
p3 = -0.5;
fallos++;
}else if (document.getElementById('p33').checked==true){
p3 = 1;
fallos++;
}else if (document.getElementById('p34').checked==true){
p3 = -0.5;
fallos++;
}else{
p3= -0.1;
blancos++;
}
nota = p1+p2+p3;
if(nota<0){
puntuacion = 0;
}else{
puntuacion = nota;
}
document.getElementById('aciertos').value = aciertos;
document.resultado.getElementById('fallos').value = fallos;
document.resultado.getElementById('blancos').value = blancos;
document.resultado.getElementById('puntuacion').value = puntuacion;
}
</script>
</head>
<body>
<FORM name="Preguntas">
<p>
<!-- Primera pregunta -->
1.- ¿Pregunta 1? </p>
<p>
<input type="radio" name="Respuesta 1" id="p11" value="A" /> Respuesta 1. </p> <p>
<input type="radio" name="Respuesta 1" id="p12" value="B" /> Respuesta 2. </p> <p>
<input type="radio" name="Respuesta 1" id="p13" value="C" /> Respuesta 3. </p> <p>
<input type="radio" name="Respuesta 1" id="p14" value="D" /> Respuesta 4. </p>
<p></p>
<!-- Segunda pregunta -->
2.- ¿Pregunta 2? </p>
<p>
<input type="radio" name="Respuesta a" id="p21" value="A" /> Respuesta a. </p> <p>
<input type="radio" name="Respuesta a" id="p22" value="B" /> Respuesta b. </p> <p>
<input type="radio" name="Respuesta a" id="p23" value="C" /> Respuesta c. </p> <p>
<input type="radio" name="Respuesta a" id="p24" value="D" /> Respuesta d. </p>
<p></p>
<!-- Tercera pregunta -->
3.- ¿Pregunta 3? </p>
<p>
<input type="radio" Respuesta e="idioma" id="p31" value="A" /> Respuesta e. </p> <p>
<input type="radio" Respuesta e="idioma" id="p32" value="B" /> Respuesta f. </p> <p>
<input type="radio" Respuesta e="idioma" id="p33" value="C" /> Respuesta g. </p> <p>
<input type="radio" Respuesta e="idioma" id="p34" value="D" /> Respuesta h. </p>
<p></p>
</FORM>
<FORM name="boton">
<input type="button" name="boton" value=" CORREGIR " onClick="corregir()"/>
</FORM>
<br><br>
<b>RESULTADO DEL TEST</b> <P>
<form name="resultado" action="">
Has acertado <input type="text" size="3" name="aciertos" value=""/> preguntas <br>
Has fallado en <input type="text" size="3" name="fallos" value=""/> preguntas <br>
Has dejado de responder <input size="3" name="blancos" type="text" value=""/> preguntas <P>
PUNTUACIÓN: <input type="text" size="5" name="puntuacion" value=""/> puntos
</form>
</body>
</html>
Gracias