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;

27 Responses to “How to Remove All Options from a Dropdown Select Box with JavaScript”

  1. Thanks, This is exactly what I was looking for. I didn’t think it was this simple…

  2. Bidyut Chakrabarty Says:

    remove items from drop down list

  3. Hey ! friend really thanks… I wasn’t think it was so easy

  4. Exactly what I was looking for, I really didn’t want to iterate through the whole array.

  5. thanks, it’s funny how simple it is

  6. thx u bro…. i thought it might be a bit work… I didn’t think it’d be this simple

  7. Who may think using this? :D
    It is very simple thx.

  8. It really helpful to me.

  9. simplest is : list.options.lenght=0; :)

  10. Aniruddha Says:

    This was very helpful!! Thanks.

  11. Thanks for your blog…
    it avoids use of any iterator..

  12. Thanks, So simple it is

  13. Brilliant.. i was looking for exactly the same..

  14. I have been working for 30 minutes for this this fixed like a charm! thx!

  15. Amazing !!!.. so simple.. Thanx for posting

  16. Amazing !!!.. so simple.. Thanx for posting !

  17. great thinking..

  18. Great stuff, thanks for the post!

  19. many thanks!!!

  20. Thank you very much for so simple way to do it. :)

  21. 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

  22. very nice post

  23. 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!

  24. Rajvinder Says:

    Thanks!it is the easiest way

  25. Thanks a lot!
    It’s amazing how much time I spent to get that… one line of code…

Leave a Reply