Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/01/2008, 00:49
Avatar de seoista
seoista
 
Fecha de Ingreso: septiembre-2003
Ubicación: Pues leyéndote
Mensajes: 1.076
Antigüedad: 20 años, 7 meses
Puntos: 59
Re: Presupuesto online

A ver si te sirven estos.
Cita:
<html>
<head>

<title></title>

</head>

<body>

<form>
<table border=0><tr><td>
Precio por unidad:</td><td><input type="text" name="precio" readonly="readonly" value="20" /> <em>Euros</em></td></tr>
<tr><td>Unidades:</td><td><input type="text" name="unidades" /></td></tr>
<tr><td>Total:</td><td><input type="text" name="total" readonly="readonly" /></td></tr>
<tr><td><button type="button" onclick="total.value = parseFloat(precio.value) * parseInt(unidades.value)" >Calcular</button>
</td></tr></table>
</form>

</body>
</html>

O este que calcula automáticamente:
Cita:
<html>

<head>

<title></title>

<script type="text/javascript">
function sumar(frm) {
s1 = frm.txt1.value;
s2 = frm.txt2.value;
if (s1=='' || isNaN(s1)) s1 = 0;
if (s2=='' || isNaN(s2)) s2 = 0;
frm.total.value = parseFloat(s1) * parseFloat(s2);
}
</script>

</head>

<body>

<form>
<table border=0><tr><td>
Precio por unidad:</td><td><input type="text" name="txt1" onkeyup = "sumar(this.form)" /> <em>Euros</em></td></tr>
<tr><td>Unidades:</td><td><input type="text" name="txt2" onkeyup = "sumar(this.form)" /></td></tr>
<tr><td>Total:</td><td><input type="text" name="total" readonly = "readonly" />
</td></tr></table>
</form>

</body>
</html>
Saludos
__________________
· No contesto por M.P.