Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add values to ListBox ?

Status
Not open for further replies.

Ajith2002

Programmer
Jul 16, 2002
30
US

How can we add values to a ListBox(Not DropDown ListBox) thru Code ?
 
First, Drop down listBoxes and listBoxes are the same "SELECT" tag in HTML so the method is the same. Let's say your SELECT id is "mySelect". Do the following :
Code:
function addToList(value, text) {
	var oSel = document.getElementById("mySelect");
	var oOption = document.createElement("OPTION");
	oSel.options.add(oOption);
	oOption.innerText = text;
	oOption.Value = value;
}
Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top