Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/01/2014, 08:26
quimerajdrs
 
Fecha de Ingreso: enero-2014
Mensajes: 6
Antigüedad: 11 años, 1 mes
Puntos: 0
Respuesta: Problemas con radio buton

[QUOTE=bathorz;4552374]Puedes sacar una idea de esto:
[HIGHLIGHT="HTML"]
<script type="text/javascript">

function prueba() {
var tot1 = 0;
var tot2 = 0;
...

Muchas gracias bathorz (Y),el codigo que me dio esta muy interesante, he tratado de acomodar el codigo a mi necesidad y no he sido capaz, usted uso "checkbox" en el código que me dejo pero no creo que se puedan usar en mi necesidad ya que usted me esta permitiendo seleccionar las dos opciones por pregunta, y solo se debería seleccionar una, es por eso que yo le puse al nombre del radio en la columna Siempre y con Frecuencia el mismo nombre.
perdon por no ser claro con la pregunta, aqui dejo el codigo un poco mejor y anexo un ejemplo para que me entienda:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Prueba</title>

<script language="javascript">

function Suma(isChecked, myValue)
{
tot = parseFloat(document.Prueba.total1.value);
myValue = parseFloat(myValue);
if (isChecked) document.Prueba.total1.value = tot + myValue;
else document.Prueba.total1.value = tot - myValue;

}
-->
</script>
<script language="javascript">

function Suma2(isChecked, myValue)
{
tot = parseFloat(document.Prueba.total2.value);
myValue = parseFloat(myValue);
if (isChecked) document.Prueba.total2.value = tot + myValue;
else document.Prueba.total2.value = tot - myValue;

}
-->
</script>
</head>
<body>
<form id="form1" name="Prueba" method="post" action="">
<table width="439" border="1">
<tr class="centrado">
<td width="144"><strong>PREGUNTAS</strong></td>
<td width="144">Siempre</td>
<td width="129">Con frecuencia</td>
</tr>
<tr>
<td>1. ¿eres puntual?</td>
<td><input type="radio" name="c0" onClick="Suma(this.checked,this.value)" value="2.00" id="1a_0"/></td>
<td ><input type="radio" name="c0" onClick="Suma2(this.checked,this.value)" value="1.34" id="1a_1" /></td>
</tr>
<tr>
<td >2. ¿Te gusta....?</td>
<td ><input type="radio" name="c1" onClick="Suma(this.checked,this.value)"value="2.00 " id="1a_5" /></td>
<td><input type="radio" name="c1" onClick="Suma2(this.checked,this.value)"value="1.3 4" id="1a_6" /></td>
</tr>
<tr>
<td>3. ¿cual es...?</td>
<td><input type="radio" name="c2" onClick="Suma(this.checked,this.value)" id="1a_10" value="2.00" /></td>
<td><input type="radio" name="c2" onClick="Suma2(this.checked,this.value)" value="1.34" id="1a_11" /></td>
</tr>
<tr>
<td>4. ¿como es...?</td>
<td><input type="radio" name="c3"onClick="Suma(this.checked,this.value)" value="2.00"id="1a_15" /></td>
<td><input type="radio" name="c3"onClick="Suma2(this.checked,this.value)" value="1.34" id="1a_17" /></td>
</tr>
<tr>
<td>5. ¿has salido...?
<td><input type="radio" name="c4"onclick="Suma(this.checked,this.value)"va lue="2.00" id="1a_16" />
<td><input type="radio" name="c4" onclick="Suma2(this.checked,this.value)"value="1.3 4" id="1a_2" /></td>
</tr>
<tr>
<td>Total de cada columna
<td><input type="text" name="total1" value="0" id="total1" />
<td><input type="text" name="total2" value="0" /></td>
</tr>
</table>
<p>&nbsp;</p>
<p>//seleccione por favor las 5 preguntas de la columna siempre, esto deberia mostrar un total de 10, ahora supongamos que yo me arrepenti y decido cambiar la pregunta 1 &quot;¿eres puntual&quot;? de Siempre a Con Frecuencia, el resultado deberia ser entonces:</p>
<p>Columna siempre= 8</p>
<p>Columna Con Frecuencia = 1.34</p>
<p>El problema como usted puede ver, es que la columna siempre no disminuye, permanece en 10 y deberia ser 8.</p>
<p>Muchas gracias por su ayuda compañero, </p>
</form>
</body>
</html>