Solved

Populating drop down box with results from mySQL query

Posted on 2008-10-15
8
214 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 19

Accepted Solution

by:
erikTsomik earned 500 total points
Comment Utility
0
 
LVL 19

Expert Comment

by:erikTsomik
Comment Utility
0
 

Author Closing Comment

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

Expert Comment

by:erikTsomik
Comment Utility
thatnks. can you post the code
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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)

762 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

7 Experts available now in Live!

Get 1:1 Help Now