Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/07/2013, 12:58
chule_chuletas
 
Fecha de Ingreso: julio-2013
Ubicación: Villa Flandria
Mensajes: 16
Antigüedad: 10 años, 10 meses
Puntos: 1
Respuesta: como realizar sumas

Si solo quieres que en el campo TOTAL se refleje el valor de la suma no necesitas hacer un form, con javascript se resuelve de la siguiente manera en el mismo archivo html.

<body>
<table width="440" border="1">
<tr>
<td width="78">producto</td>
<td width="73"> entrada</td>
<td width="112">total</td>
</tr>
<tr>
<td><label for="cantidad"></label>
<input type="text" name="cantidad" id="cantidad" /></td>
<td><label for="suma"></label>
<input type="text" name="suma" id="suma" /></td>
<td><label for="total"></label>
<input type="text" name="total" id="total" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><button name="button" id="button" value="Sumar" onClick="sumar();"/></td>
</tr>
</table>
</body>
</html>

<script>

{literal}

function sumar(){
var cant1 = $('cantidad').value;
var cant2 = $('cantidad').value;

$('total').value = parseFloat(cant1) + parseFloat(cant2);
}

{/literal}

</script>


En color azul te marque las modificaciones.

Saludos