Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/04/2010, 05:52
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: Ayuda con Switch case en Javascript

Hola

Fijate en los cambios que he realizado

Código Javascript:
Ver original
  1. function calculo(des)
  2. {
  3. switch(des)
  4. {
  5. case "1":
  6. document.getElementById('desc').value = "hola";
  7. break;
  8. case "2":
  9. document.getElementById('desc').value = "Adios";
  10. break;
  11. }
  12. }
  13.  
  14. </script>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <title>Documento sin t&#237;tulo</title>
  17. </head>
  18.  
  19. <body>
  20. <p>Descuento del 5&#37;<input type="radio" name="R1" onClick=calculo('1');>
  21. <br>
  22. Descuento del 10%<input type="radio" name="R1" onClick=calculo('2');>
  23. <br>
  24. IMPORTE:<input type="text" name="impor" size="20" value = "200">
  25. DESCUENTO:<input type="text" id="desc" name="desc" value="" size="20" >
  26. </p>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />