Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/05/2007, 16:17
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 23 años
Puntos: 772
Re: calculadora simple

Hola menfis_megadisco

Prueba esto:

Código PHP:
<html>
<
head>
<
script>
function 
sumar(frm) {
  
n1 parseInt(frm.txt1.value);
  if (
isNaN(n1)) n1 0;
  
n2 parseInt(frm.txt2.value);
  if (
isNaN(n2)) n2 0;
  
document.getElementById('suma').innerHTML 'Total = '+ (n1 n2);
}
</script>
</head>
<body>
<form>
<input type="text" name="txt1" onkeyup="sumar(this.form)" />
<input type="text" name="txt2" onkeyup="sumar(this.form)" />
</form>
<p id="suma">Total = 0</p>
</body>
</html> 
Saludos,