473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How can I load the options for an HTML Select element from a file?

I am working with an HTML-based form that uses a select element that
requires about 200 options. Is there a way that I can load, or select
one of these options from a file, rather than hardcode them into the
select element?

Thanks
Jul 20 '05 #1
7 4252
jo******@comcast.net (John C) wrote:
I am working with an HTML-based form that uses a select element that
requires about 200 options. Is there a way that I can load, or select
one of these options from a file, rather than hardcode them into the
select element?


What sort of file? Where is the file? What languages are supported on
your server? How often does the list of 200 options change?

Anyway, there's no way of doing this in HTML. It can be done server
side (with ASP or PHP or SSI, etc.) or less reliably client side (with
JavaScript).

Of course, a list of 200 options is quite difficult for the user to
use and the best solution might be to avoid it altogether.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2
Steve Pugh <st***@pugh.net> wrote:
jo******@comcast.net (John C) wrote:
I am working with an HTML-based form that uses a select element that
requires about 200 options. Is there a way that I can load, or select
one of these options from a file, rather than hardcode them into the
select element?


What sort of file? Where is the file? What languages are supported on
your server? How often does the list of 200 options change?

Anyway, there's no way of doing this in HTML. It can be done server
side (with ASP or PHP or SSI, etc.) or less reliably client side (with
JavaScript).

Of course, a list of 200 options is quite difficult for the user to
use and the best solution might be to avoid it altogether.


What would be an easier way to let the user enter, for example, his
country on a form where he is filling out his mailing address,
assuming that "countryID" is a foreign key in the Addresses table?

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #3
Harlan Messinger <hm*******************@comcast.net> wrote:
Steve Pugh <st***@pugh.net> wrote:
Of course, a list of 200 options is quite difficult for the user to
use and the best solution might be to avoid it altogether.
What would be an easier way to let the user enter, for example, his
country on a form where he is filling out his mailing address,


If the country is only ever going to be printed out on mailing labels
then a plain text field will suffice. It doesn't matter if some people
put UK, others put United Kingdom, and others England, the mail will
still get there. Typing the country will usually be quicker than
finding it in a drop down (unless you happen to live in the Federated
States of Micronesia).

If the country is needed by some server side application (e.g.to
calculate shipping costs) then a select element is the best option.
But a list of countries is a fairly atypical case - everyone knows
what country they live, and sorting the countries alphabetically is
pretty much the norm (take a list of countries and randomise the
order, or even just sort them by contintent, and see how much longer
it takes you to find your country).

But if the data is less familiar then a select element may not be the
best choice. For example, text inside select elements isn't found by
browsers' search facilities so it can be harder to find the option
you're looking for.
assuming that "countryID" is a foreign key in the Addresses table?


I can only guess as to what this means. It's not HTML is it?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #4
On Thu, 1 Apr 2004, Steve Pugh wrote:
If the country is needed by some server side application (e.g.to
calculate shipping costs) then a select element is the best option.


For sure, a select list with hundreds of entries is a most unsuitable
thing to present to any user, if it can possibly be avoided.

Better, could be to let them type it in for themselves, and do a
preliminary submission of the form; then on the server side, if you
don't get an exact match with what you expected, you can look-up your
own list of countries (using some kind of fuzzy match algorithm) to
find some normalised names which seem to match, and feed the form back
to them, with the accepted parameters already filled-in, and with a
pull-down containing your (manageable number of) suggestions for the
missing field(s). However, this isn't really a topic for the HTML
group, since it involves server-side processing.
Jul 20 '05 #5
On Thu, 01 Apr 2004 13:15:07 +0100, Steve Pugh <st***@pugh.net> wrote:
jo******@comcast.net (John C) wrote:
I am working with an HTML-based form that uses a select element that
requires about 200 options. Is there a way that I can load, or select
one of these options from a file, rather than hardcode them into the
select element?


What sort of file? Where is the file? What languages are supported on
your server? How often does the list of 200 options change?

Anyway, there's no way of doing this in HTML. It can be done server
side (with ASP or PHP or SSI, etc.) or less reliably client side (with
JavaScript).

Of course, a list of 200 options is quite difficult for the user to
use and the best solution might be to avoid it altogether.

Steve


Another option is to have the user enter the first letter, and have that
lead to a select dropdown with only those countries. Again, this is
complicated.

Better still, have a separate page linked which lists all the (perhaps
2-letter) country codes and allow the user to look it up and enter that
code in a text box. Confirmation page can list the 2-letter code entered
along with the country name that matches to ensure no error in entering or
referencing was made.
Jul 20 '05 #6

"Steve Pugh" <st***@pugh.net> wrote in message
news:59********************************@4ax.com...
Harlan Messinger <hm*******************@comcast.net> wrote:
Steve Pugh <st***@pugh.net> wrote:
Of course, a list of 200 options is quite difficult for the user to
use and the best solution might be to avoid it altogether.
What would be an easier way to let the user enter, for example, his
country on a form where he is filling out his mailing address,


If the country is only ever going to be printed out on mailing labels
then a plain text field will suffice. It doesn't matter if some people
put UK, others put United Kingdom, and others England, the mail will
still get there. Typing the country will usually be quicker than
finding it in a drop down (unless you happen to live in the Federated
States of Micronesia).


Granted--almost. Even ignoring the possibility that someone might type in
nonsense (which I'll overlook because that's true for any free-form text
field), someone could type in a genuine country name but in a foreign
language that the post office may not recognize.

If the country is needed by some server side application (e.g.to
calculate shipping costs) then a select element is the best option.
But a list of countries is a fairly atypical case - everyone knows
what country they live, and sorting the countries alphabetically is
pretty much the norm (take a list of countries and randomise the
order, or even just sort them by contintent, and see how much longer
it takes you to find your country).

But if the data is less familiar then a select element may not be the
best choice. For example, text inside select elements isn't found by
browsers' search facilities so it can be harder to find the option
you're looking for.


Right. It's just that you didn't mention this caveat, and there are
certainly many 200-item lists one could have in which the items are in some
kind of intuitive order.
Jul 20 '05 #7
jo******@comcast.net (John C) wrote in message news:<3b**************************@posting.google. com>...
I am working with an HTML-based form that uses a select element that
requires about 200 options. Is there a way that I can load, or select
one of these options from a file, rather than hardcode them into the
select element?

Thanks


Thanks to everyone who responded to this message, you have supplied
me with some good questions and technical approaches. I am working in
PHP and HTML and have access to a MySQL db. From a logic
point-of-view, here is what I came up with last night:

- user accesses page with form
- user requests access to the 200 records
- begin loop:
- sql query gets one record
- PHP writes <option>record info</option>
- end loop
- results displayed as select list, possibly in a pop-up window
- user makes selection
- selection returned with form information to PHP processing

Any further comments/suggestions are greatly appreciated.
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: gonzalo briceno | last post by:
I have been using phplib for a while and I really like the framework except for form creation. Maybe it is me but I in my opinion there isn't a good way to create forms or should I say, everything...
0
by: tomhath | last post by:
Can someone give an opinion whether this is a dumb approach? I want to generate a list of OPTION elements for s SELECT element, but I can't see any (clean) way to use a template on a list of...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
7
by: Hal Vaughan | last post by:
I have a sample script from a book ("Beginning JavaScript" by Paul Wilton) that removes or adds a choice to a <SELECT> element. The <FORM> is form1 and the <SELECT> is theDay. The example uses...
9
by: netclectic | last post by:
I'm dynamically adding options to a select list in javascript and i need to be able to set the height of the option, but setting style.height has not effect, I also tried style.pixelHeight but no...
3
by: Tony Kim | last post by:
Hi everyone, i have an assignment that needs immediate attention and was hoping i would be able to get some help here. im trying to create 3 option boxes that are linked together. for...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
4
by: teknoshock | last post by:
I have created a page with multiple drop down boxes, all populated with the same options. My problem is, for 12 dropdown boxes and 40 choices per box, I end up with a massive file. Also, if I...
1
by: madflytom | last post by:
Hello, I'm trying to move the options of one select list to another select list. The "source" select list is divided into optgroups, and the "target" select list is not. I want to somehow keep...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.