Advertisement
angeldp

opos2004_HTML5

Apr 13th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script type="text/javascript">
  6.     function convertir(){
  7.         var accion = document.getElementById("selector");
  8.         var cantidad = document.getElementById("importe").value;
  9.         if (accion.value=="p2e"){
  10.             document.getElementById("resultado").value = Math.round(parseInt(cantidad) / 166.386);
  11.         }
  12.         if (accion.value=="e2p"){
  13.             document.getElementById("resultado").value = Math.round(parseInt(cantidad) * 166.386);
  14.         }
  15.     }
  16.     window.onload=function(){
  17.         boton=document.getElementByID("boton");
  18.         boton.setAttribute("onClick","convertir()");
  19. }
  20. </script>
  21. <style>
  22.     form{max-width:350px;}
  23.     p{text-align:center;}
  24.     label{
  25.         display:inline-block;
  26.         width:9em;
  27.         text-align:left;}
  28.     select{width:100%;}
  29. </style>
  30. </head>
  31. <body>
  32. <form name="conversor">
  33. <p><label for="importe">Importe a convertir: </label><input type="text" name="importe" id="importe" /></p>
  34. <p><label for="resultado">Resultado: </label><input type="text" name="resultado" id="resultado" /> </p>
  35. <p><label></label>
  36.     <select id="selector">
  37.         <option value="p2e">Pesetas a euros</option>
  38.         <option value="e2p">Euros a pesetas</option>
  39.     </select>
  40. </p>
  41. <p><input type="button" id="boton" value="Convertir" /></form>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement