How to update selection list contents from a server database based upon user data entry

J

Jim Cobban

I am trying to create a web page in which the contents of one selection list
depends upon which element in another selection list is chosen, but where
the information to populate the first selection list comves from an SQL
database on the web server.

There are a couple of these situations in my application but, for example,
the first list might be a list of counties, and the second list a list of
states/provinces. Obviously the names of counties depend upon which
state/province is chosen, but there are too many possibilities to be able to
embed them within the web page itself. So when the user selects a
state/province I need to go to the server to ask for the list of counties.

I have seen a number of posts that sort of address this issue. For example
it is suggested to use <script src="a URL"/> to ask the server side code to
send up data of type "text/javascript". However the examples do not seem to
address how the server side code would know which state/province the user
had selected.

If there is a web site that addresses this sort of thing, I would appreciate
any pointers.
 
E

enrique

Don't have a web site for you, but I can recommend a strategy for its
implementation.

Every time someone makes a new selection in list #1 (to populate list
#2), the page has to submit a form to the server. The server will then
know (from the form contents) what was selected. It then has to
regenerate the same page, but populate list #1 with the end user's
selection and populate list #2 with the right contents based on that
selection.

To enable the form being submitted when the end user select from list
#1, this is where your javascript comes into play. I'll leave it up to
you to do the research on how to process an event that gets fired when
an html <select> changes its value. When that event fires, the form on
that page needs to get posted.

epp
 
J

Jim Cobban

Thank you. I honestly don't understand why such an obvious capability is
not documented in any of the Javascript cookbooks that I have read.

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top