?
Solved

Populating drop down box with results from mySQL query

Posted on 2008-10-15
8
Medium Priority
?
220 Views
Last Modified: 2012-05-05
I have to tables one is called "make the other is "model"

The make table has a "id"  and "make" field
The model table has "id" "idmake" and "model" field

these tables hold a list of car manufactures and there models.  I have the first drop down box that list all the manufactures.  How do I get the second one to only list there models?

I'm using coldfusion with mysql

Thank you

0
Comment
Question by:sonicimpulse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22722815
Are you trying to create dependent drop downs ?

<select name='model'>
<cfloop query='queryname'>
   <options value="#id#">#model#</options>
</cfloop>
</select>
0
 

Author Comment

by:sonicimpulse
ID: 22724650
There is two drop down boxes one where they click the manufactures name.  This box has every car manufacture listed in it.  This drop down does work perfectly.

The second box I want to list only the models of cars for what ever manufacture the user picked.  This is the box I can't get to work.

The model table has a field called idmake  This field contains the same number as the id field in the make table.  I wrote it out above.  This is how I can link the tables together.



0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22724703
you need another query saying that

where idmake=#form.manufactire#
There a custom  tag available
http://projects.nateweiss.com/nwdc/downloads/cf/CF_TwoSelectsRelated.zip

Or
take a look at this
http://www.coldfusionjedi.com/index.cfm/2008/9/14/Triple-Related-Selects-and-interesting-CFDIV-trick
Or you can use javascript
0
Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

 

Author Comment

by:sonicimpulse
ID: 22725283
Maybe this will help.  Below is the code to my list box.  Can I use the onchange to save the ID in a variable.  If so how would I do that?

<select name="ltype" onChange="" >
                            <cfoutput query="qtype">
                              <option value="#id#|#type#" descript="#tdescription#" tabindex="3">#type#</option>
                            </cfoutput>
                          </select>  
0
 
LVL 19

Accepted Solution

by:
erikTsomik earned 2000 total points
ID: 22725321
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22725326
0
 

Author Closing Comment

by:sonicimpulse
ID: 31506346
Thanks for that tutorial.  I got it working perfectly
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22735859
thatnks. can you post the code
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question