lunes, 26 de septiembre de 2011

una funcion de javascript desde select

<html>
<head>
    <title>Ejemplo select</title>
   
<script language="JavaScript">

function dimePropiedades()
{
    var texto
    texto = "El numero de opciones del select: " + document.formul.seleccion.length
   
    var indice = document.formul.seleccion.selectedIndex
    texto += "\nIndice de la opción escogida: " + indice
   
    var valor = document.formul.seleccion.options[indice].value
    texto += "\nValor de la opcion escogida: " + valor

    var textoEscogido = document.formul.seleccion.options[indice].text
    texto += "\nTexto de la opcion escogida: " + textoEscogido
    alert(texto)
}
</script>
</head>
<body>

<form name="formul">
Valoracion sobre esta pagina:
<select name="seleccion">
<option value="10">Muy bien
<option value="5" selected>Regular
<option value="0">Muy mal
</select>
<br>
<br>
<input type=button value="Dime propiedades" onclick="dimePropiedades()">
</form>
</body>
</html>




No hay comentarios:

Publicar un comentario