...

View Full Version : How can I clear a Select listbox that was populated dynamically?



mesh2005
06-16-2007, 06:14 PM
I use the following code but it didn't work:<br>


var selectList = document.getElementById("mylist");
for (i=0;i<selectList.options.length;i++)
{
selectList.removeChild(selectList.options.item(i));
}

Please help.

glenngv
06-16-2007, 07:04 PM
Simply setting the options length to zero will delete all the items.

selectList.options.length = 0;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum