Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / April 2005



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Cobban - 28 Apr 2005 17:49 GMT
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.
enrique - 28 Apr 2005 18:11 GMT
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
kaeli - 28 Apr 2005 18:17 GMT
> If there is a web site that addresses this sort of thing, I would appreciate
> any pointers.

And to think I just wrote that up a couple days ago.  :)

Here ya go.
http://www.ipwebdesign.net/kaelisSpace/useful_dynamicSelectsDB.html

Signature

--
~kaeli~
If a turtle doesn't have a shell, is he homeless or naked?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jim Cobban - 29 Apr 2005 06:26 GMT
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.

> > If there is a web site that addresses this sort of thing, I would appreciate
> > any pointers.
[quoted text clipped - 3 lines]
> Here ya go.
> http://www.ipwebdesign.net/kaelisSpace/useful_dynamicSelectsDB.html
kaeli - 29 Apr 2005 17:20 GMT
> 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.

You're welcome.  :)

Signature

--
~kaeli~
To steal ideas from one person is plagiarism; to steal from
many is research.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

RobB - 29 Apr 2005 19:00 GMT
> 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.

(snip)

Probably missed this:

http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.