Reputation: 1455
Please help how to clear dropdownlist control in Javascript
Upvotes: 2
Views: 9035
Reputation: 1038830
document.getElementById('idofselectbox').options.length = 0;
Upvotes: 8
Reputation: 73112
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.
Upvotes: 0