JavaScript - Función parece bloquear

 
Vista:

Función parece bloquear

Publicado por Jhon J Hernández (5 intervenciones) el 23/06/2012 16:59:29
Les voy a poner todo el código, es largo. Se trata de un programa que cuenta turnos de trabajo y luego calcula la cantidad de horas diurnas, nocturas, festivas... La cuenta al inicio se hace dos veces para verificar que se hizo bien.
El problema se presenta pues estoy empezando a hacer cambios para que al escoger un radbutton se cambien las variaciones del turno, pero al hacer clic no pasa nada

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<title>Documento sin título</title>
<script type="text/javascript">
function incrementar(elem){
document.getElementById(elem).value = parseInt(document.getElementById(elem).value,10) + 1;
}
 
function pasar(){
var tx1 = document.getElementById('tx1');
var tx2 = document.getElementById('tx2');
var tx5 = document.getElementById('tx5');
document.getElementById('tx3').value = tx1.value;
document.getElementById('tx4').value = tx2.value;
document.getElementById('tx6').value = tx5.value;
tx1.value = 0;
tx2.value = 0;
tx5.value = 0;
}
 
function calcular(){
//Primer turno
document.getElementById('txOD').value = parseInt(document.getElementById('tx1').value,10) *8;
 
//Segundo turno
//Una hora extra diurna, por eso se multiplica por 1
var extrasDiurnasIncrementar = parseInt(document.getElementById('tx2').value,10) *1;
document.getElementById('txED').value = parseInt(document.getElementById('txED').value,10) + extrasDiurnasIncrementar;
var diurnasIncrementar = parseInt(document.getElementById('tx2').value,10) *8;
document.getElementById('txOD').value = parseInt(document.getElementById('txOD').value,10) + diurnasIncrementar;
 
//Tercer turno
//2 horas extras diurnas, por eso se multiplica por 2
var extrasDiurnasIncrementar = parseInt(document.getElementById('tx5').value,10) *2;
document.getElementById('txED').value = parseInt(document.getElementById('txED').value,10) + extrasDiurnasIncrementar;
var diurnasIncrementar = parseInt(document.getElementById('tx5').value,10) *8;
document.getElementById('txOD').value = parseInt(document.getElementById('txOD').value,10) + diurnasIncrementar;
}
 
function cambiar1(){
//Adecuamos las variaciones del turno
limpiar();
}
 
function cambiar2(){
//Adecuamos las variaciones del turno
limpiar();
document.getElementById('txTurno1').value = "8 - 18";
document.getElementById('txTurno2').value = "8 - 17";
document.getElementById('txTurno3').value = "8 - 20";
 
 
 
}
 
function limpiar(){
//Para eso hay que resetear los valores
document.getElementById('tx1').value = 0;
document.getElementById('tx2').value = 0;
document.getElementById('tx3').value = 0;
document.getElementById('tx4').value = 0;
document.getElementById('tx5').value = 0;
document.getElementById('tx6').value = 0;
 
document.getElementById('tx7').value = 0;
document.getElementById('tx8').value = 0;
document.getElementById('tx9').value = 0;
document.getElementById('tx10').value = 0;
document.getElementById('tx11').value = 0;
document.getElementById('tx12').value = 0;
document.getElementById('tx13').value = 0;
document.getElementById('tx14').value = 0;
}
 
</script>
</head>
 
<body>
<form id="form1" name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="RadioGroup1" value="opción" id="RadioGroup1_0" onclick="cambiar1();"/>
6-14</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="opción" id="RadioGroup1_1" onclick="cambiar2();"/>
8-18</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="opción" id="RadioGroup1_2" onclick="cambiar3();"/>
14-22</label>
<br />
</p>
<table width="614" border="1">
<tr>
<td width="106" id ="uno"><label>
<input type="text" name="txTurno1" id="txTurno1" />
</label></td>
<td width="13">&nbsp;</td>
<td width="87">
<label>
<input type="button" name="1" id="boton1" value="Agregar" onclick="incrementar('tx1');"/>
</label>
</td>
<td width="16">&nbsp;</td>
<td width="144"><label>
<input type="text" name="tx1" id="tx1" value="0"/>
</label></td>
<td width="9">&nbsp;</td>
<td width="193"><input type="text" name="tx3" id="tx3" value="0"/></td>
</tr>
<tr>
<td><label>
<input type="text" name="txTurno2" id="txTurno2" />
</label></td>
<td>&nbsp;</td>
<td><input type="button" name="2" id="boton2" value="Agregar" onclick="incrementar('tx2');"/></td>
<td>&nbsp;</td>
<td><input type="text" name="tx2" id="tx2" value="0"/></td>
<td>&nbsp;</td>
<td><input type="text" name="tx4" id="tx4" value="0"/></td>
</tr>
<tr>
<td><label>
<input type="text" name="txTurno3" id="txTurno3" />
</label></td>
<td>&nbsp;</td>
<td><input type="button" name="boton2" id="boton5" value="Agregar" onclick="incrementar('tx5');"/></td>
<td>&nbsp;</td>
<td><input type="text" name="tx5" id="tx5" value="0"/></td>
<td>&nbsp;</td>
<td><input type="text" name="tx6" id="tx6" value="0"/></td>
</tr>
</table>
<p>
<input type="button" name="3" id="boton3" value="De nuevo" onclick="pasar();" />
 
</p>
<p>
<input type="button" name="boton" id="boton4" value="Calcular" onclick="calcular();" />
</p>
<table width="405" border="1">
<tr>
<td width="171">&nbsp;</td>
<td width="99">Diurnas</td>
<td width="113">Nocturnas</td>
</tr>
<tr>
<td width="171">ORDINARIAS</td>
<td><label>
<input type="text" name="txOD" id="txOD" value="0"/>
</label></td>
<td><label>
<input type="text" name="txON" id="txON" value="0"/>
</label></td>
</tr>
<tr>
<td>EXTRAS</td>
<td><label>
<input type="text" name="txED" id="txED" value="0"/>
</label></td>
<td><label>
<input type="text" name="txEN" id="txEN" value="0"/>
</label></td>
</tr>
<tr>
<td>FESTIVAS</td>
<td><label>
<input type="text" name="txFD" id="txFD" value="0"/>
</label></td>
<td><label>
<input type="text" name="txFN" id="txFN" value="0"/>
</label></td>
</tr>
<tr>
<td>FESTIVAS EXTRAS</td>
<td><label>
<input type="text" name="txFED" id="txFED" value="0"/>
</label></td>
<td><label>
<input type="text" name="txFEN" id="txFEN" value="0"/>
</label></td>
</tr>
</table>
<p>&nbsp; </p>
</form>
</body>
</html>

Sé que falta la funcion 3... como dije estaba haciendo esa parte cuando noté que no pasaba nada.
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
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Función parece bloquear

Publicado por xve (2100 intervenciones) el 24/06/2012 17:01:36
Hola Jhon, nos puedes indicar a que linea te refieres con el radiobutton??
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Función parece bloquear

Publicado por Jhon J Hernández (5 intervenciones) el 26/06/2012 05:48:54
Ya sé cual es el problema, hay varias instrucciones con tex que no existen. Al parecer la página cuando llega ahí no funciona bien más.

Los tex sólo llegan al 6.

Otra cosa los 3 option buttons de Dreamweaver no funcionan si uno usa más de dos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar