How to Remove All Options from a Dropdown Select Box with JavaScript
To remove all options from a dropdown select box with JavaScript, simply set the length property of the dropdown box to 0. For instance, if a dropdown select box is defined as follows:
<select name='Dropdown' id='Dropdown'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
Use this JavaScript to remove all the options in the dropdown select box.
document.getElementById('Dropdown').length = 0;
September 18, 2007 at 3:08 pm
Thanks, This is exactly what I was looking for. I didn’t think it was this simple…
January 30, 2008 at 11:19 pm
remove items from drop down list
March 13, 2008 at 10:23 pm
Hey ! friend really thanks… I wasn’t think it was so easy
October 13, 2008 at 3:33 am
Exactly what I was looking for, I really didn’t want to iterate through the whole array.
October 30, 2008 at 7:01 am
nice post
November 19, 2008 at 2:31 pm
thanks, it’s funny how simple it is
November 27, 2008 at 3:18 pm
thx u bro…. i thought it might be a bit work… I didn’t think it’d be this simple
December 19, 2008 at 12:06 am
thanks
December 25, 2008 at 2:45 am
Who may think using this?
It is very simple thx.
April 2, 2009 at 2:35 am
It really helpful to me.
April 30, 2009 at 12:22 pm
simplest is : list.options.lenght=0;
June 25, 2009 at 10:15 am
This was very helpful!! Thanks.
June 30, 2009 at 12:51 am
Thanks for your blog…
it avoids use of any iterator..
July 27, 2009 at 5:33 am
Thanks, So simple it is
August 5, 2009 at 2:38 am
Brilliant.. i was looking for exactly the same..
August 11, 2009 at 3:53 pm
I have been working for 30 minutes for this this fixed like a charm! thx!
August 13, 2009 at 6:39 am
Amazing !!!.. so simple.. Thanx for posting
August 13, 2009 at 6:40 am
Amazing !!!.. so simple.. Thanx for posting !
August 18, 2009 at 10:32 pm
great thinking..
August 19, 2009 at 8:08 pm
Great stuff, thanks for the post!
November 6, 2009 at 11:03 am
many thanks!!!
December 4, 2009 at 5:32 am
Thank you very much for so simple way to do it.
December 14, 2009 at 7:45 am
I wish I found this a couple of days ago, I was trying to iterate through the array and set the options to null
Many Thanks
January 1, 2010 at 5:52 pm
very nice post
January 20, 2010 at 5:14 am
LOL! I was actually dreading having to make the loop and start combating this problem I was having and presto, it is a one line solution! How awesome!
January 22, 2010 at 2:15 am
Thanks!it is the easiest way
March 10, 2010 at 10:04 am
Thanks a lot!
It’s amazing how much time I spent to get that… one line of code…