Monday, August 23, 2010

Dynamic add option to Select Element

//first clear the content
obj=document.getElementByID("mysel")
mysize=obj.length
for (x=mysize-1;x>-1;x--){
obj.remove(x)
}
myobj=document.createElement("option")
myobj.text=myary[x]
myobj.value=myary[x]
myobj.selected =true
if (navigator.appName=="Microsoft Internet Explorer")
obj.add(myobj)
else
obj.appendChild(myobj)

No comments:

Post a Comment