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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT OPTGROUP - adding dynamically !

Status
Not open for further replies.

fixthebug2003

Programmer
Joined
Oct 20, 2003
Messages
294
Location
US
Hi,
How can we dynamically add/delete the OPTGROUP to a SELECT Form element (list-box) using javascript?

Fixthebug2003
 
check out the faqs - always the best place to start.

faq216-4766



Code:
function create(){

optGroup = document.createElement('optgroup')

var objSelect=document.forms(0).elements(0);
var objOption=document.createElement("option")

objOption.innerHTML = "tset"
objOption.value = "simon"

optGroup.label = "simple"

objSelect.appendChild(optGroup)
optGroup.appendChild(objOption)
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top