Please help how to clear dropdownlist control in Javascript
A:
function RemoveItems()
{
var objDrpList = document.getElementById ('theIdOfYourDdl');
for(i=objDrpList.length-1; i>=0; i--)
{
if(objDrpList.options[i].selected)
{
objDrpList.options[i] = null;
}
}
}
EDIT:
Darin's answer is actually the way to go. Both work, but less code is better.
RPM1984
2010-09-28 09:42:42
+2
A:
document.getElementById('idofselectbox').options.length = 0;
Darin Dimitrov
2010-09-28 09:43:21