Dropdownlist - number of display elements

I have a dropdown on my webpage.

When I click on it, the list with all the elements expands. But this list is very long.

How can I change it to get a list with (for example) 5 displayed items and using the scroll bar next to them.

If this is not possible, how can I do this with a ListBox? I know this is a Rows property, but can I declare how many lines are displayed continuously after expanding the list.

+4
source share
2 answers

This control, of course, will appear on the page as a standard <select> control.

In this case, the height of the list after it falls is determined by the browser, and you do not control this. You will notice that when the list approaches the foot of the page, the browser will use the scroll bar as you expected, but not with the number of elements you might want.

My only suggestion was to explore the options offered by some client side dropdown add-ons. You can find some jQuery to help.

A simple Google search for "jQuery dropdowns" gave this article as the main result: 38 jQuery and CSS Drop Down Multi Level Menu Solutions . If you cannot find something here, there are also many similar sites in the search results.

+2
source

I think this post provides you with several different solutions to your problem.

http://blogs.msdn.com/b/rakkimk/archive/2011/05/02/dropdownlist-html-select-vertical-scrollbar-number-of-items.aspx

+1
source

All Articles