Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/01/2005, 15:54
NormaS
 
Fecha de Ingreso: enero-2005
Mensajes: 1
Antigüedad: 19 años, 3 meses
Puntos: 0
Exclamación Cotrol sobre radiobuttons

Hola que tal!

Quisiera pedirles ayuda para el manejo de radiobuttons con javascript, tengo un formulario en el cual aparecen 4 preguntas y cuando se da click en un boton aparecen las respuestas que contestaron y las respuestas correctas, mi problema esta en que cuando no se contesta una pregunta mi codigo ya no funciona porque no sé como determinar si no se contesto a alguna pregunta. Tal vez no me estoy explicando bien, pero envío mi código a ver si pudieran ayudarme porfavor, se los agradecere mucho, de antemano muchas gracias....... Norma .

<HTML>
<head>
<title>Ejemplo de radiobuttons</title>
</head>

<BODY>
<SCRIPT language="JavaScript">
function muestraResp()
{
var tures1,tures2,tures3,tures4;
for (tures1=0;tures1<activ4.preg1.length;tures1++){
if (activ4.preg1[tures1].checked)
break;
}
for (tures2=0;tures2<activ4.preg2.length;tures2++){
if (activ4.preg2[tures2].checked)
break;
}
for (tures3=0;tures3<activ4.preg3.length;tures3++){
if (activ4.preg3[tures3].checked)
break;
}
for (tures4=0;tures4<activ4.preg4.length;tures4++){
if (activ4.preg4[tures4].checked)
break;
}

activ4.turesp1.value = activ4.preg1[tures1].value;
activ4.turesp2.value = activ4.preg2[tures2].value;
activ4.turesp3.value = activ4.preg3[tures3].value;
activ4.turesp4.value = activ4.preg4[tures4].value;

activ4.respcorr1.value = "1,000,000,000 de kilómetros cúbicos";
activ4.respcorr2.value = "95%";
activ4.respcorr3.value = "0.01%";
activ4.respcorr4.value = "0.0001%";

}

</SCRIPT>
<FORM NAME="activ4">
<p>1. &iquest;Cu&aacute;l es el volumen total de agua en la Tierra?</p>
<input type="radio" name="preg1" value="1,000 kil&oacute;metros c&uacute;bicos">
a) 1,000 kil&oacute;metros c&uacute;bicos
<input type="radio" name="preg1" value="1,000,000 de kil&oacute;metros c&uacute;bicos">
b) 1,000,000 de kil&oacute;metros c&uacute;bicos
<input type="radio" name="preg1" value="1,000,000,000 de kil&oacute;metros c&uacute;bicos">
c) 1,000,000,000 de kil&oacute;metros c&uacute;bicos

<p>2. &iquest;Qu&eacute; porcentaje del agua de la Tierra se encuentra en los
oc&eacute;anos?</p>
<input type="radio" name="preg2" value="25%">a) 25%
<input type="radio" name="preg2" value="50%">b) 50%
<input type="radio" name="preg2" value="95%">c) 95%

<p>3. &iquest;Qu&eacute; porcentaje del agua de la Tierra se encuentra en los
lagos?</p>
<input type="radio" name="preg3" value="10%">a) 10%
<input type="radio" name="preg3" value="25%">b) 25%
<input type="radio" name="preg3" value="0.01%">c) 0.01%

<p>4. &iquest;Qu&eacute; porcentaje del agua de la Tierra se encuentra en los
r&iacute;os?</p>
<p>
<input type="radio" name="preg4" value="10%">a) 10%
<input type="radio" name="preg4" value="0.0001%">b) 0.0001%
<input type="radio" name="preg4" value="0.01%">c) 0.01%

<p>
<input type="button" name="respuestas" value="Respuestas" onClick="muestraResp()">
</p>
<table width="93%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="57%">Pregunta</th>
<th width="23%">Tu respuesta</th>
<th width="20%">Respuesta Correcta</th>
</tr>
<tr>
<td width="57%" height="16">1. &iquest;Cu&aacute;l es el volumen total de
agua en la Tierra?</td>
<td width="23%" height="16">
<input type="text" readonly name="turesp1" size="35" maxlength="35">
</td>
<td width="20%" height="16">
<input type="text" readonly name="respcorr1" size="35" maxlength="35">
</td>
</tr>
<tr>
<td width="57%">2. &iquest;Qu&eacute; porcentaje del agua de la Tierra se
encuentra en los oc&eacute;anos?</td>
<td width="23%">
<input type="text" readonly name="turesp2" size="10" maxlength="10">
</td>
<td width="20%">
<input type="text" readonly name="respcorr2" size="10" maxlength="10">
</td>
</tr>
<tr>
<td width="57%">3. &iquest;Qu&eacute; porcentaje del agua de la Tierra se
encuentra en los lagos?</td>
<td width="23%">
<input type="text" readonly name="turesp3" size="10" maxlength="10">
</td>
<td width="20%">
<input type="text" readonly name="respcorr3" size="10" maxlength="10">
</td>
</tr>
<tr>
<td width="57%">4. &iquest;Qu&eacute; porcentaje del agua de la Tierra se
encuentra en los r&iacute;os?</td>
<td width="23%">
<input type="text" readonly name="turesp4" size="10" maxlength="10">
</td>
<td width="20%">
<input type="text" readonly name="respcorr4" size="10" maxlength="10">
</td>
</tr>
</table>
</FORM>
</body>
</HTML>