Click here to get back home

Problems and questions regarding HTML form SELECT elements

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Problems and questions regarding HTML form SELECT elements Matthew Cox 09-18-2007
Posted by Matthew Cox on September 18, 2007, 6:38 pm
Please log in for more thread options


Hi,

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?


Posted by Adrienne Boswell on September 18, 2007, 9:49 pm
Please log in for more thread options


Gazing into my crystal ball I observed Matthew Cox
@k79g2000hse.googlegroups.com:

> Hi,
>
> 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?
>
>

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
else
'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
answer.



--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


Posted by Jukka K. Korpela on September 19, 2007, 2:32 am
Please log in for more thread options
Scripsit Matthew Cox:

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

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

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

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
http://www.cs.tut.fi/~jkorpela/forms/choices.html

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

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

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.

> That the magic number of IE is 30 entries before
> the vertical scroll bar shows up.

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")
http://www.cs.tut.fi/~jkorpela/


Posted by André Gillibert on September 22, 2007, 9:34 am
Please log in for more thread options
Matthew Cox wrote:

> Hi,
>
> 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.

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:
http://www.w3.org/TR/html4/interact/forms.html#h-17.6

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.


> I'm starting to
> think that this isn't possible.

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.

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

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

> That the magic number of IE is 30 entries before
> the vertical scroll bar shows up.
>

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.

--

Similar ThreadsPosted
Select a radio button have another value passed on also in form- How? October 26, 2004, 12:25 pm
Form and nested elements November 10, 2004, 11:57 am
Visibility of form elements December 3, 2004, 8:01 pm
form elements which should not be submitted March 9, 2006, 3:17 pm
INPUT type="image" and Form Elements October 6, 2004, 12:04 pm
Using multiple button type="submit" elements within a form April 15, 2005, 4:24 pm
HTML September 18, 2006, 4:53 pm
Extending HTML Elements April 19, 2007, 8:46 am
A few questions about the html dtd October 16, 2006, 3:50 am
HTML Interview Questions December 26, 2006, 2:02 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap