Note: I have moved to wordpress. New URL is "Technology Made Easy"

Wednesday, May 16, 2007

How to remove all options from a list box using javascript?


function clearListBox(listboxID)
{
// returns 1 if all items are sucessfully removed
// otherwise returns zero.
var mylistbox = document.getElementById(listboxID);
if(mylistbox == null)
return 1;
while(mylistbox.length > 0)
{
mylistbox.remove(0);
}
return 1;
}

about me

I am a software engineer from India...
Coding was my hobby...
now, Coding is my profession...

Ratings by outbrain