tags:

views:

18

answers:

3

Please help how to clear dropdownlist control in Javascript

A: 

Simply remove its child elements which are <option>

Umair Ashraf
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
+2  A: 
document.getElementById('idofselectbox').options.length = 0;
Darin Dimitrov