Solved

Populating drop down box with results from mySQL query

Posted on 2008-10-15
8
215 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
  • 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
 

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 19

Accepted Solution

by:
erikTsomik earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now