Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <script type="text/javascript">
- function convertir(){
- var accion = document.getElementById("selector");
- var cantidad = document.getElementById("importe").value;
- if (accion.value=="p2e"){
- document.getElementById("resultado").value = Math.round(parseInt(cantidad) / 166.386);
- }
- if (accion.value=="e2p"){
- document.getElementById("resultado").value = Math.round(parseInt(cantidad) * 166.386);
- }
- }
- window.onload=function(){
- boton=document.getElementByID("boton");
- boton.setAttribute("onClick","convertir()");
- }
- </script>
- <style>
- form{max-width:350px;}
- p{text-align:center;}
- label{
- display:inline-block;
- width:9em;
- text-align:left;}
- select{width:100%;}
- </style>
- </head>
- <body>
- <form name="conversor">
- <p><label for="importe">Importe a convertir: </label><input type="text" name="importe" id="importe" /></p>
- <p><label for="resultado">Resultado: </label><input type="text" name="resultado" id="resultado" /> </p>
- <p><label></label>
- <select id="selector">
- <option value="p2e">Pesetas a euros</option>
- <option value="e2p">Euros a pesetas</option>
- </select>
- </p>
- <p><input type="button" id="boton" value="Convertir" /></form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement