Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/03/2013, 10:45
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: Como crear un select con Javascript

Agrego
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">
  4. <title>Crear Select</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.  
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. window.onload = function(){
  10. var campo_dia=document.getElementById('dias');
  11. for (var i=0; i < 31; i++){
  12. campo_dia.options[i]=new Option(i+1, 'v_'+(i+1)); // texto-valor
  13. }
  14. }
  15.  
  16. //]]>
  17. </head>
  18. <form action="#">
  19. <select name="dias" id="dias">
  20. <option value=""><!-- fix w3c --></option>
  21. </form>
  22. </body>
  23. </html>

Solo resta saber de dónde se obtienen los pares texto-valor, incluso podría ser el mismo para ambos

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