Is there a max number of options (values) in HTML drop down control?

53,908

Solution 1

Does anyone know how many options a drop down list can have? Is it unlimited?

I imagine it is unlimited in theory, obviously not in practice as a computer's RAM and the specific browser's limitations come into play.

How many before performance degrades?

Again, this would depend on a few factors, at the least the specific browser, the computer's memory and processing power.


EDIT: From experience, I have had drop down lists with thousands of options. It wasn't ideal though because who wants to scroll through all of those? This is why an auto-complete of some type is more desirable for numerous reasons, especially the end user's experience.

Solution 2

Update: Based on DannyG, tested on Ubuntu with Firefox on a 4GB mem pc, limit was far beyond 10k tags. My current Firefox is set to use up to 3GB and it has reached a 100k options, but for that, you'd have to change the default config of the browser I guess.

We opted to use an Ajax autocomplete as replacement in all cases that 30+ options where given.

Both Firefox and Chrome limited to 10k options in Windows 64b with 4GB ram on default config.

Tested with JSFiddle http://jsfiddle.net/Mare6/

for (var i=0; i<10000; i++) {
    var name = "Option "+i;
    var sel = document.getElementById("list");
    sel.options[sel.options.length] = new Option(name,i);
}
<a>Testing Select</a>
<select id="list"></select>

Regards,

Solution 3

I've used right around 500 in a list with no noticeable performance impact if that helps!

Solution 4

Yes, the maximum for Chrome and Safari is 10000 items for select elements at least.

The relevant lines in the Chrome source can be found here: Defined max of 10000, Code that enforces limit and puts error in console

Firefox seems to have no practical limit from my testing.

Solution 5

In my experience the performance degradation is generally on the side of the user, my golden rule (learned somewhere) is seven options, give or take a few.

On a more SW related basis, probably the top range of Integer.

EDIT: BTW This is kind of relevant from Atwood

Share:
53,908

Related videos on Youtube

Steve T
Author by

Steve T

Star Command Galaxies (Steam) Star Command (iOS / Android) Snooz Music Alarm Clock (iOS) Star Command Galaxies: Focused mostly on low-level rendering with Unity. Mesh generation, chunking maps, packing textures, and other improvements to the projected pixel art rendering pipeline. Star Command: Developed this game along with two pixel-artists who came to me with the idea. I handled the programming, asset pipeline, and prepared the game for release on iOS/Android app stores. Snooz Music Alarm Clock: Created an alarm app so I could wake up to my iTunes music collection. The major feature was being a 3rd-party app that stayed active to allow music playback in the morning. It also offers sleep timer and can display simple weather forecast. Naval Fight: Created this game as my first real iPhone project to learn Objective-C, XCode, the SDK, and various APIs.

Updated on July 09, 2022

Comments

  • Steve T
    Steve T almost 2 years

    Does anyone know how many options a drop down list can have? Is it unlimited? How many before performance degrades?

    • STT LCU
      STT LCU over 12 years
      i know this question is quite old, but to future reference i have used a select with 30800 options and worked quite well (when the php script doesn't go out of time to fetch the values)
    • Scott C Wilson
      Scott C Wilson over 8 years
      A bigger issue might be the timeout if an AJAX database query is populating the list. So people landing here might also want to search on AJAX timeouts if this is their situation.
  • Steve T
    Steve T about 10 years
    fascinating, especially since Mozilla's docs state "Permitted content Zero or more <option> or <optgroup> elements." - developer.mozilla.org/en-US/docs/Web/HTML/Element/…
  • DJG22
    DJG22 over 9 years
    Not true, i have a select with 80000 options, chrome allows 30.000 in one machine and 20.800 on another, first machine has 8Gbs of RAM second one has 4GB, so its mostly based on computer specs.
  • Sebas
    Sebas over 7 years
    well on mobile device it's a different matter