Solved

Populating drop down box with results from mySQL query

Posted on 2008-10-15
8
217 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

830 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