Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/12/2009, 12:01
Avatar de dcreate
dcreate
 
Fecha de Ingreso: octubre-2009
Ubicación: Veracruz
Mensajes: 536
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: Calculadora php,

mira haber si te gusta algo asi:

calculadora.php
Código php:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Documento sin t&iacute;tulo</title>
  6. </head>
  7. <?php
  8. if(isset($_GET['submit']) && !empty($_GET['num1']) && !empty($_GET['num2']))
  9. {
  10. $num1=$_GET['num1'];
  11. $num2=$_GET['num2'];
  12. $calculo=$_GET['calculo'];
  13. if ($calculo == "mas")
  14. {$x = $num1 + $num2;
  15. echo '<script>alert("EL RESULTADO ES '.$x.'");</script>';}
  16. elseif ($calculo == "menos")
  17. {$x = $num1 - $num2;
  18. echo '<script>alert("EL RESULTADO ES '.$x.'");</script>';}
  19. elseif ($calculo == "X")
  20. {$x = $num1 * $num2;
  21. echo '<script>alert("EL RESULTADO ES '.$x.'");</script>';}
  22. else
  23. {$x = $num1 / $num2;
  24. echo '<script>alert("EL RESULTADO ES '.$x.'");</script>';}
  25.  
  26. }
  27. ?>
  28. <form action="calculadora.php" method="get">
  29. Primer numero:
  30. <input type="text" name="num1"><br>
  31. Segundo numero:
  32. <input type="text" name="num2"><br>
  33. <p> Operacion<br>
  34. <input type="radio" name="calculo" value="mas" checked>
  35. +<br>
  36. <input type="radio" name="calculo" value="menos">
  37. -<br>
  38. <input type="radio" name="calculo" value="X">
  39. x<br>
  40. <input type="radio" name="calculo" value="dividir">
  41. /<br>
  42. <input type="submit" name="submit" value="Calcular"><input type="reset" value="Borrar">
  43. </form>
  44. </body>
  45. </body>
  46. </html>

suerte