Ver Mensaje Individual
  #10 (permalink)  
Antiguo 19/10/2015, 11:15
Avatar de Cassers
Cassers
 
Fecha de Ingreso: octubre-2015
Mensajes: 16
Antigüedad: 8 años, 7 meses
Puntos: 3
Respuesta: ¿Como crear input dinamico a partir de un select?

vale entiendo, entonces te paso un html que hace eso

Código HTML:
Ver original
  1.     <head>
  2.         <meta charset="utf-8">
  3.         <meta http-equiv="expires" content="-1" />
  4.         <title>Problema</title>
  5.     </head>
  6.     <body>
  7.         <select id="myselect" onchange="mostrar_control()">
  8.             <option value="1">opción1</option>
  9.             <option value="2">opción2</option>
  10.             <option value="3">opción3</option>
  11.             <option value="4">opción4</option>
  12.             <option value="5">opción5</option>
  13.             <option value="Nuevo">añadir nuevo elemento</option>
  14.         </select>
  15.         <input id="Texto" type="text" style="visibility: hidden">
  16.     </body>
  17. </html>
  18.  
  19.     function mostrar_control(){
  20.         var select = document.getElementById("myselect");
  21.         var inputText = document.getElementById("Texto");
  22.         if(select.options[select.selectedIndex].value == "Nuevo"){
  23.             inputText.style.visibility = "visible";
  24.         }else{
  25.             inputText.style.visibility = "hidden";
  26.         }
  27.     }