Foros del Web » Programando para Internet » Javascript »

Función bloqueadora

Estas en el tema de Función bloqueadora en el foro de Javascript en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 22/06/2012, 22:35
 
Fecha de Ingreso: noviembre-2004
Ubicación: Medellín
Mensajes: 121
Antigüedad: 19 años, 5 meses
Puntos: 1
Busqueda Función bloqueadora

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

<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>

Etiquetas: html, input, botones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 10:04.