Solved

Populating drop down box with results from mySQL query

Posted on 2008-10-15
8
219 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 

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 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

729 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