Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/12/2010, 14:02
roser24
 
Fecha de Ingreso: marzo-2010
Mensajes: 127
Antigüedad: 14 años, 1 mes
Puntos: 2
Pregunta problema con calculadora

Hola chicos,tengo que realizar una calculadora pero no se porque no llego a visualizar en la caja de texto los simbolos de los operandos.
mi codigo actual es el siguiente:
Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script language="Javascript">
  4.  
  5. function fcero(){document.f1.numr.value=document.f1.numr.value+0;}
  6. function funo(){document.f1.numr.value=document.f1.numr.value+1;}
  7. function fdos(){document.f1.numr.value=document.f1.numr.value+2;}
  8. function ftres(){document.f1.numr.value=document.f1.numr.value+3;}
  9. function fcuatro(){document.f1.numr.value=document.f1.numr.value+4;}
  10. function fcinco(){document.f1.numr.value=document.f1.numr.value+5;}
  11. function fseis(){document.f1.numr.value=document.f1.numr.value+6;}
  12. function fsiete(){document.f1.numr.value=document.f1.numr.value+7;}
  13. function focho(){document.f1.numr.value=document.f1.numr.value+8;}
  14. function fnueve(){document.f1.numr.value=document.f1.numr.value+9;}
  15. function fopera(){
  16. var op=document.f1.numr.value;
  17. var a=parseInt(document.f1.numr.value);
  18. var b=parseInt(document.f1.nuevo.value);
  19. if(op=="+"){
  20.  
  21. var a=+b;
  22. document.f1.numr.value=a;
  23.  
  24. }
  25. if(op=="-"){
  26. var resul=a-b;
  27. document.f1.numr.value=resul;
  28.  
  29. }
  30.        
  31.  
  32. }
  33.  
  34. function fcalcular(){document.f1.numr.value=document.f1.nuevo.value;document.f1.nuevo.value="";}
  35.  
  36.  
  37.  
  38. </script>
  39. </head>
  40. <body>
  41. <form name="f1" action="calculadora.html" method=GET>
  42. <table border=1>
  43. <tr><td colspan=3><label name="lblnum"></label><input type="text" name="numr"></td></tr>
  44. <input type="text" name="nuevo" value="">
  45. <tr><td><input type=button name="n1" value="  1  " onclick="funo()"></td><td><input type=button name="n2" value="  2  "onclick="fdos()"></td><td><input type=button name="num" value="  3  "onclick="ftres()"></td>
  46. <td><input type=button value="   +   "onclick="fopera()"></td></tr>
  47. <tr><td><input type=button name="n4" value="  4  "onclick='fcuatro()'></td><td><input type=button name="cinco" value="  5  "onclick='fcinco()'></td><td><input type=button name="seis"value="  6  "onclick='fseis()'></td><td><input type=button value="   -    "onclick='fopera()'></td></tr>
  48. <tr><td><input type=button name="n7" value="  7  "onclick='fsiete()'></td><td><input type=button name="n8" value="  8  "onclick='focho()'></td><td><input type=button name="n9" value="  9  "onclick='fnueve()'></td><td><input type=button value="   x   "onclick='fopera()'></td></tr>
  49. <tr><td><input type=reset name="x" value="  c  "></td><td><input type=button value="  0  " name="n0" onclick="fcero()"></td><td><input type=button name="igual" value="  =  "onclick="fcalcular()"></td><td><input type=button value="   /   "onclick="fopera()"></td></tr>
  50. </form>
  51. </table>
  52. </body>
  53. </html>

Muchas gracias de antemano.y que paseis una Feliz Navidad