[Javascript] <select>

Mckinney, Lori K lkmckinn at ingr.com
Wed Sep 4 08:36:56 CDT 2002


You need to first create an option element
	var optionElement=document.createElement("OPTION");
	optionElement.value=value;
	optionElement.text=display;

 then add it to the select
	selectElement.add(optionElement,index);

The second argument to the add is the index indicating where you want to put the option in the select.  If you don't include it it, the option will be added to the end of the options collection.  If you use 0, it will be the first thing in the list.

Here are a couple of references (watch wrapping)
createElement
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/createelement.asp?frame=true
add Method
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/add.asp?frame=true

-----Original Message-----
From: Iztok Polanic [mailto:iztokp at amis.net]
Sent: Wednesday, September 04, 2002 8:24 AM
To: javascript at LaTech.edu
Subject: [Javascript] <select>


Hi!

How to fill a <select> box?
I tried this but it doesn't work:

document.forms["FORMA"].elements["SELECT"].value = 'test';

Bye,

Iztok

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list