471,599 Members | 1,227 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

Have a very long select element repeated

Hi All

I have to build a page which includes a select element (as a drop down
menu) with all the country names in it. However I just found out that
the need to be repeated many times so the client can select as many
country as they can in their around the world trip planning.

I don't want to repeat this long list multiple times, because I want
to save bandwidth. Is there a more efficient way to do this rather
than using JavaScript to repeat the code on the client side? (which I
don't know how to do yet).

Thanks

Aug 22 '07 #1
7 3383
Scripsit mc*****@gmail.com:
I have to build a page which includes a select element (as a drop down
menu) with all the country names in it.
Tell the people who told you to do that what the drawbacks are. You should
be able to list down half a dozen good reasons easily.
However I just found out that
the need to be repeated many times so the client can select as many
country as they can in their around the world trip planning.
Technically, it need not be repeated, since you can use the MULTIPLE
attribute in the select element. However, people will generally not know
that they can select multiple elements and how to do that, and even if they
do, its is a nightmare to actually make such selections.

Using a set of checkboxes (associated with country names) would produce
_much_ better usability. Users would have to scroll the _page_ then, but is
this any worse than having to scroll the drop down _menu_? No, it's actually
much better, more useable.

Perhaps even better, you could include a text input field (input type="text"
or textarea) where people can type in the names of the countries. You would
then need to parse - in the server-side form handler - the names, maybe even
with synonym recognition and loose matching (taking, say, "finland",
"finnland", and "finlandia" all matching "Finland"). More work to you, maybe
better usability to users.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 22 '07 #2
Jukka K. Korpela wrote:
Scripsit mc*****@gmail.com:
>I have to build a page which includes a select element (as a drop down
menu) with all the country names in it.

Tell the people who told you to do that what the drawbacks are. You should
be able to list down half a dozen good reasons easily.
[...]
Using a set of checkboxes (associated with country names) would produce
_much_ better usability.
My sentiments exactly: Dropdown menus are almost always bad. To select one
or more items out of FEW choices, use radiobuttons or checkboxes.

For a larger number of choices, use text entry boxes and parse the result
server-side.

I always love it when I'm looking for a local representative of a company
that has a handful of offices around the world, and the web droid who did
the page crammed every country in existence into a drop-down list.

Or credit card expiration dates from the past.

Or birth year selectors that go from 1900 to 2007.

Or all the other shit with which marketing folks cripple potentially useful
web pages.

robert
Aug 22 '07 #3
Scripsit Robert Latest:
I always love it when I'm looking for a local representative of a
company that has a handful of offices around the world, and the web
droid who did the page crammed every country in existence into a
drop-down list.
.... as well as some non-existent countries, such as "Serbia and Montenegro",
and missing some of the existing countries, like "Serbia" and "Montenegro".

Allowing _all_ countries (for some definition for "country") might be
adequate e.g. in a form where you ask for a user's postal address or
nationality. Then the list of countries needs to be maintained somehow,
since changes _will_ take place. It need not be more difficult to maintain
it in the HTML source than to maintain it in the form handler, though. The
point is that one shouldn't aim at a list of all countries unless it's
really _needed_.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 22 '07 #4
Robert Latest wrote:
My sentiments exactly: Dropdown menus are almost always bad. To select
one
or more items out of FEW choices, use radiobuttons or checkboxes.

For a larger number of choices, use text entry boxes and parse the result
server-side.
That's one of the rare occasion where AJAX can slightly improve user's
experience by providing auto-completion when typing the country name in a
text entry box, as Google Suggest does.

Of course, it's just an *improvement*. The code must be written without
JavaScript, and then, add the JavaScript code that intercepts key strokes.

--
You can contact me at <ta*****************@yahoDELETETHATo.fr>
Aug 22 '07 #5
Jukka K. Korpela wrote:
Using a set of checkboxes (associated with country names) would produce
_much_ better usability.
Generally I would agree, but in this case there are over 300 items in
the list. Checkboxes aren't a good alternative when there are that many
items.
Perhaps even better, you could include a text input field (input
type="text" or textarea) where people can type in the names of the
countries. You would then need to parse - in the server-side form
handler - the names, maybe even with synonym recognition and loose
matching (taking, say, "finland", "finnland", and "finlandia" all
matching "Finland"). More work to you, maybe better usability to users.
Yes. If the user knows which countries he wants to visit, allowing him
to type them, rather than sort through an exhaustive list to find them
would be better.
Aug 22 '07 #6
Scripsit Scott Bryce:
Jukka K. Korpela wrote:
>Using a set of checkboxes (associated with country names) would
produce _much_ better usability.

Generally I would agree, but in this case there are over 300 items in
the list. Checkboxes aren't a good alternative when there are that
many items.
I don't think there are that many countries in world, even under a fairly
broad meaning for "country". A list of _areas_ could be arbitrarily long, of
course.

Anyway, if it's too much for a set of checkboxes, it's even stronger too
much for a select list. Imagine yourself scrolling up and down in a list of
300 items, with about a dozen of them visible at a time, trying to
remember what you have already selected and what you wish to select, and
trying to figure out whether you should try to find the United Kingdom under
"B" (Britain), "E" (England) or "G" (Great Britain) or maybe "U".
If the user knows which countries he wants to visit, allowing him
to type them, rather than sort through an exhaustive list to find them
would be better.
And then you could accept all the commonly used synonyms for a country.
There will be input errors, inevitably, that would be avoided in select or
checkbox approaches, though.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 22 '07 #7
Jukka K. Korpela wrote:
Scripsit Robert Latest:
>I always love it when I'm looking for a local representative of a
company that has a handful of offices around the world, and the web
droid who did the page crammed every country in existence into a
drop-down list.

... as well as some non-existent countries, such as "Serbia and
Montenegro", and missing some of the existing countries, like "Serbia"
and "Montenegro".
In the United States we have a similar situation, where dropdowns
listing the states and state-equivalents (the District of Columbia,
Puerto Rico, US Virgin Islands, etc.) including nations that were once
under US administration as part of the UN Trust Territory of the Pacific
but that became independent nations years ago. Though I admit I haven't
seen one that includes the Panama Canal Zone.
Aug 22 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mike Chirico | last post: by
4 posts views Thread by hawat.thufir | last post: by
19 posts views Thread by zzw8206262001 | last post: by
112 posts views Thread by Prisoner at War | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.