Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/09/2010, 19:06
oscarbt
 
Fecha de Ingreso: abril-2009
Ubicación: Colombia
Mensajes: 949
Antigüedad: 15 años
Puntos: 27
Problema al sumar campos en JavaScript

Tengo un problema al sumar datos que recibo de dos cajas de texto y que a través de una función los sumo, los convierto en ParseInt pero aun así no me funciona:

Aca el codigo:


Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>Cuadrado</title>
  5. <script languaje="JavaScript">
  6.           function area()
  7.          {
  8.             base=document.datos.base.value;
  9.                
  10.             altura=document.datos.altura.value;
  11.             document.datos.resultado.value=base*altura/2;
  12.           }
  13.       </script>
  14.      
  15.       <script languaje="JavaScript">
  16.           function sumar()
  17.          {
  18.            
  19.                
  20.           ladoa=parseInt(document.getElementById('ladoa').value);  
  21. ladob=parseInt(document.getElementById('ladob').value);
  22. ladoc=parseInt(document.getElementById('ladoc').value);
  23. perimetro=ladoa + ladob + ladoc ;
  24. document.getElementById('perimetro').value=perimetro.toFixed(2);  
  25. // 2 decimales
  26.          
  27.           }
  28.       </script>
  29.      
  30. </head>
  31.  
  32. <body>
  33.  
  34. <center><h1><b>Calculo de área y perimetro de un Triangulo</b></h1></center>
  35. <br />
  36. <hr />
  37. <form name="datos">
  38. <h3>VALOR LADO A </h3>
  39. <input  type="text" name="ladoa" id="ladoa" size="10" />&nbsp;&nbsp; &nbsp;&nbsp;
  40. <h3>VALOR LADO B </h3>
  41. <input  type="text" name="ladob" id="ladob" size="10"   />&nbsp;&nbsp; &nbsp;&nbsp;
  42. <h3>VALOR LADO C </h3>
  43. <input  type="text" name="ladoc" id="ladoc" size="10"  />&nbsp;&nbsp; &nbsp;&nbsp;
  44. <h3>VALOR DE LA BASE </h3>
  45. <input  type="text" name="base" size="10"  />&nbsp;&nbsp; &nbsp;&nbsp;
  46. <h3>VALOR DE LA ALTURA </h3>
  47. <input  type="text" name="altura" size="10"  />&nbsp;&nbsp; &nbsp;&nbsp;
  48. <h3>VALOR PERIMETRO </h3>
  49. <input type="text" name="perimetro">
  50.   <h3>VALOR AREA </h3>
  51. <input type="text" name="resultado">
  52. <br>
  53.   <br>
  54.   <input type="button" value="Calcular" onClick="area(); sumar()" >
  55. </form>
  56. <br />
  57.  
  58. </body>
  59.  </html>

Cual es mi error?

Agradezco la ayuda