Advertisement
gtw7375

Marcando opcões (radio). HTML + JAVASCRIPT

Jul 30th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.92 KB | None | 0 0
  1. <hmtl> <head>
  2.     <script>  
  3.     function salario (opcao) {
  4.         var hora = document.getElementById("hora").value;
  5.  
  6.             if(opcao.op[0].checked) {
  7.                     var sal1 = eval(hora) * 12;
  8.                         alert("Seu salário é" + " " + "U$" + sal1);
  9.                 }
  10.             if(opcao.op[1].checked) {
  11.                     var sal2 = eval(hora) * 15;
  12.                         alert("Seu salário é" + " " + "U$" + sal2);
  13.                 }
  14.             if(opcao.op[2].checked) {
  15.                     var sal3 = eval(hora) * 18;
  16.                         alert("Seu salário é" + " " + "U$" + sal3);
  17.                 }
  18.             }      
  19.   </script>  
  20.  </head>  
  21. <body>  <center>
  22.         Horas aula <input type="text" id="hora"  />
  23.                 <br><br>
  24.     <form name="opcao">
  25.         Nivel 1 <input type="radio" value="Nivel 1" name="op"/>
  26.         Nivel 2 <input type="radio" value="Nivel 2" name="op"/>
  27.         Nivel 3 <input type="radio" value="Nivel 3" name="op"/>
  28.     </form>
  29.                 <br><br>
  30.         <input type="button" value="Calcular" id="botao" onclick="salario (opcao)"/>
  31.     </center>
  32. </body>  
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement