Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/01/2011, 13:22
javiercitox
 
Fecha de Ingreso: diciembre-2009
Ubicación: Valparaíso
Mensajes: 118
Antigüedad: 14 años, 5 meses
Puntos: 3
Respuesta: Obtener id de option

No será que quieres el value???
prueba esto....

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.     function propiedades() {
  3.         var texto;
  4.         texto = "El numero de opciones del select: " + document.getElementById("miSelect").length;        
  5.         var indice = document.getElementById("miSelect").selectedIndex;
  6.         texto += "\nIndice de la opcion escogida: " + indice;        
  7.         var valor = document.getElementById("miSelect").options[indice].value;
  8.         texto += "\nValor de la opcion escogida: " + valor;
  9.         var textoEscogido = document.getElementById("miSelect").options[indice].text;
  10.         texto += "\nTexto de la opcion escogida: " + textoEscogido;
  11.         alert(texto);
  12.     }
  13. </script>

Código HTML:
Ver original
  1. <form name="miForm" action="#">
  2. Elige una opción:
  3.     <select id="miSelect">
  4.         <option value="10">Muy bien </option>
  5.         <option value="5" selected="selected">Regular </option>
  6.         <option value="0">Muy mal </option>
  7.     </select>
  8. <br />
  9. <input type="button" value="Propiedades" onclick="propiedades()" />
  10. </form>