Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/09/2010, 14:07
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: doble evento OnChange??

oscarbt:

No es necesario recurrir a ajax, con esta script lo podés hacer


Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es" >
  4. <title>Ocultar/mostrar inputs onchange</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="description" content="x" />
  7. <meta name="keywords" content="x" />
  8. <meta http-equiv="Content-Language" content="ES" />
  9. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  10. <meta http-equiv="imagetoolbar" content="no" />
  11. <meta name="copyright" content="&copy; 2006, Guillermo Gianello" xml:lang="es" lang="es" />
  12. <meta name="author" content="http://emprear.com"  xml:lang="es" lang="es" />
  13.  
  14. <style type="text/css">
  15. /*<![CDATA[*/
  16.  
  17. input#entero, input#frac {
  18. display: none;
  19. border: solid 2px #000;
  20. }
  21.  
  22. /*]]>*/
  23.  
  24. <script type="text/javascript">
  25. //<![CDATA[
  26.  
  27. function generar_inputs(){
  28.  
  29.  var valor = document.numeros.tipo.options[document.numeros.tipo.selectedIndex].value;
  30.  var campo_entero = document.getElementById('entero');
  31.  var campo_frac = document.getElementById('frac');
  32.  
  33.  var dis_e = campo_entero.style;
  34.  var dis_f = campo_frac.style;
  35.  alert(valor);
  36.  
  37. if(valor =='entero'){
  38. dis_e.display = 'block';
  39. dis_f.display = 'none';
  40. }else if(valor =='frac'){
  41. dis_e.display = 'block';
  42. dis_f.display = 'block';
  43. }else{
  44. dis_e.display = 'none';
  45. dis_f.display = 'none';
  46. }
  47.  
  48. }
  49.  
  50. //]]>
  51. </head>
  52. <div>
  53. <form name="numeros" method="post" action="#">
  54. <select name="tipo" onchange="generar_inputs();">
  55. <option selected="selected" value="">Seleccione tipo de número</option>
  56. <option value="entero">Entero</option>
  57. <option value="frac">Fraccionario</option>
  58. <input type="text" id="entero" name="entero" value="1000" size="4" />
  59. <input type="text" id="frac" name="frac" value="005" size="3" />
  60. </form>
  61. </div>
  62. <!-- ©2000 Emprear.com -->
  63. </body>
  64. </html>

una demo en
http://foros.emprear.com/jsdemo/comb..._campo_oc.html

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.