Problems and questions regarding HTML form SELECT elements

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I've been searching the net all day today trying to figure out how one
would accomplish what I originally thought would be a fairly straight
forward and simple thing. The problem I'm trying to solve is that the
designer would like to limit the total number of entires shown when
you click on the drop-down arrow of a select box. I'm starting to
think that this isn't possible.

I've tried the following with no luck:

- Setting the height attribute on the select element
- Setting a style height for the select attribute
- Modifying the same through Javascript
- Setting the style overflow-y to scroll
- Setting the size of the select element

At some point in my browsing someone claimed that the vertical scroll
bars are controlled by the OS/Browser and there are no ways to change
this using JS or CSS. That the magic number of IE is 30 entries before
the vertical scroll bar shows up.

That's where I'm at right now. Can anyone help shed some light on this?

Re: Problems and questions regarding HTML form SELECT elements

Gazing into my crystal ball I observed Matthew Cox

Quoted text here. Click to load it
Quoted text here. Click to load it

I know you can do the checking server side, eg. (asp)
if ubound(split(selectbox,", ")) > number then
   'too much
elseif selectbox = "" then
   'nothing at all
   'just right
end if

I would image there might be a way to do that client side, but I'm not a
javascript person.  Maybe post to comp.lang.javascript for a better

Adrienne Boswell at Home
Arbpen Web Site Design Services
Please respond to the group so others can share

Re: Problems and questions regarding HTML form SELECT elements

Scripsit Matthew Cox:

Quoted text here. Click to load it

Since it appears to be something presentational, it would have been natural
to start from CSS, not HTML.

Quoted text here. Click to load it

Just tell the dee-ziner that it isn't possible. If it isn't strictly true,
it's just a white lie. It's certainly not possible in HTML, and it wouldn't
be useful anyway. The real problem is in the dee-ziner's mind: (s)he wants
controls to look cool, instead of being useable. That's a particularly bad
way of being control freak.

Drop-down controls created using select boxes are relatively rarely the best
way to deal with a one-out-of-many choice, and a manifestly poor approach to
many-out-of-many choices. For a general discussion, see

If the default behavior for the drop-down is not suitable, the odds are that
you are way beyond the scope of applicability of <select>. If you want fewer
options to pop up, then you are just a control freak, or a slave of a
control freak. (I'm trying hard to express this stronger, but I'm so poor in
such things.)

Quoted text here. Click to load it

Could be. In any case, it would be browser dependent and would depend on
non-HTML technologies that might be switched off for various reasons.

Quoted text here. Click to load it

Could be. It was when I just tested it: with 30, no scroll bar, with 31,
scroll bar. This might sound nasty if you planned to use <select> for
selecting day of month, but who on &Planet; would dream of doing so? :-)
Typing in one or two digits is surely easier than picking up a number from a
list of 31 numbers.

Jukka K. Korpela ("Yucca")

Re: Problems and questions regarding HTML form SELECT elements

Matthew Cox wrote:

Quoted text here. Click to load it

Even though that could only make sense in a very narrow set of  
presentation layouts, strangely, there's a standard way to give a size  
information (just a guideline) in HTML:

This applies to list box representations, not to "drop-down boxes", but  
user agents are free to interpret them as they wish.
Actually, IE6 behavior is to use a list box with N rows whenever SIZE=N is  
specified, otherwise, a combo box is used, even when there's only one or  
two options!

Opera 8.54, Mozilla 1.7, Netscape 1.22 & higher and 1X 1.0 share the same  
behavior on Win32 as well as Opera and Dillo on GNU/Linux, but other  
behaviors, such as the one of Elinks, are perfectly sane.

Quoted text here. Click to load it

It isn't. The designer cannot *limit* the total number of entries "viewed"  
at once for any sense of the word "viewed". HTML isn't an imperative  
language, it is a declarative language.
You can just give a guideline, interpreted or not, depending on whether it  
makes sense to the user agent and whether the user agent or the user  
wishes to accept this imposed value.

Quoted text here. Click to load it

With ActiveX, you can. But ActiveX is a quite offensive technology:  
Executing arbitrary binary code on the client machine.

Quoted text here. Click to load it

This probably depends on the OS and version of IE and maybe user settings,  
screen resolution and font sizes.
With Windows 98 SE and IE6, for 12 or more entries, there's a scroll bar.


Site Timeline