Agregar elemento a un Select

25/08/2003 - 19:25 por D | Informe spam
Hola Foreros!

Alguien sabe como puedo hacerle
para agregarle elementos a un <select>
al estar ejecutandose la pagina.?

De antemano Gracias!!
 

Leer las respuestas

#1 Sashka
25/08/2003 - 20:17 | Informe spam
Prueba esto:

<html>
2<head>
<script Language="JavaScript">
function agrega () {
var oOption = document.createElement("OPTION")
oOption.text="Sin selección"
oOption.value="loquesea"
cbo2.add(oOption)
if (cbo2.children.length > 1) {
cbo2.children(cbo2.children.length - 1).swapNode(cbo2.children(0));
cbo2.options.selectedIndex=0 }
}

</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<select name="cbo2">
</select>

<a href="javascript:;" onClick="javascript:agrega()">agrega opcion</a>
</body>
</html>

Sashka

"" escribió en el mensaje
news:09c801c36b2d$e797ee20$
Hola Foreros!

Alguien sabe como puedo hacerle
para agregarle elementos a un <select>
al estar ejecutandose la pagina.?

De antemano Gracias!!

Preguntas similares