Tema: Otro botón
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2012, 20:31
yonerflash
 
Fecha de Ingreso: noviembre-2004
Ubicación: Medellín
Mensajes: 121
Antigüedad: 19 años, 6 meses
Puntos: 1
Busqueda Otro botón

Hice cambios al programa que incrementa el valor de un texbox usando un botón para que hiciera lo mismo con otro botón y otro texbox, pero no funciona.
<script language = "javascript" type="text/javascript">
function incrementar(){
var inputText = document.getElementById('tx1');
var valor = parseInt(document.getElementById('tx1').value);
valor += 1;
inputText.value = valor;
}
function incrementar2(){
var inputText = document.getElementById('tx2');
var valor = parseInt(document.getElementById('tx2').value);
valor += 1;
inputText.value = valor;
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="614" border="1">
<tr>
<td width="106">6 am - 2:30 pm</td>
<td width="13">&nbsp;</td>
<td width="87">
<label>
<input type="button" name="1" id="boton1" value="Agregar" onClick="incrementar();"/>
</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>6 am - 14:30 pm</td>
<td>&nbsp;</td>
<td><input type="button" name="2" id="boton2" value="Agregar" onClick="incrementar2();"/></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>
</table>
<p>
<input type="button" name="3" id="boton3" value="De nuevo" />
</p>
<p>&nbsp; </p>
</form>
</body>
</html>