Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating drop-down menu list with DB table data

Status
Not open for further replies.

attick111

Programmer
Nov 28, 2001
21
US
I have a Location table (LocationID, LocationName, LocationAddr, LocationCity, etc) and on my form page I have two drop-down menu list. What I want the customer to do is from the first drop down menu list, first select a city (query will perform a...select LocationID, locationAddr, LocationCity from LocationTbl). Having selected the LocationCity, say Minnesota, What I want to happen is for the second drop down menu list to be populated with only the Location addresses in Minnesota. And so if I have only 4 locations in Minnesota, I want to see in the list the 4 addresses.

I am new to ColdFusion and this happens to be my first project. I will be grateful for any assistance.

Thanks,
George
 
there are several ways to approach this

one way requires a round-trip from the browser to the server, such that when a choice in the first dropdown is detected (using the onChange event), the form automatically submits, the selected city value is used to do the database lookup for the second dropdown, and the form is sent back to the browser

the problem with this method is that if there are other fields on the form that have not yet been filled in, you shouldn't really consider it a form submission and throw a bunch of errors at the user -- in addition, if there are form fields already filled in, you have to grab them and re-populate the fields back to the browser

another method is to send full contents of both dropdowns to the browser, and let the visible contents of the second be determined by the choice in the first -- see for an example of how to do it (don't be put off by the name "popu menus" because they are actually talking about SELECT lists)

yet another method is to ask the user to make a city choice on a separate page before proceeding to the actual form, which will then have only one dropdown -- this is sorta like the roundtrip method, without the complication of handling all the form fields

so to answer your question, the coldfusion depends a lot on the design of your page

rudy
 
Rudy,
Thanks for your suggestions. This page in particular is sort of a pre-confirmation page but before the user completes processing the request I want the user to select the location where, say they want to take a class. There will be only two form objects for location data(i.e drop down menu lists) on this page and once the two have been select (i.e City and location name) these will be displayed together with other Shopping Cart data like total cost of classes registered.

George

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top