JavaScript - ¿como podría hacer esto? (radio)

 
Vista:

¿como podría hacer esto? (radio)

Publicado por sumando (1 intervención) el 10/01/2014 17:05:32
¿podría por favor ayudarme? tengo problemas con esa encuesta, en la parte de abajo dejo el código de lo que hice, y dentro del código esta la explicación del problema. Gracias de antemano.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!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)"value="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 </p>
</form>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder