Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dropdown

Status
Not open for further replies.

danarashad

Programmer
Nov 2, 2006
115
US
Does anyone know a way for a Second Dropdown Populated by first drop down.

<cfquery name="school" datasource="#datasource#">
select name,ID from Schools order by name asc
</cfquery>



<form >
School: <select name="school" id="school">
<option value="">- Select A School-</option>
<cfoutput query="school">
<option value="#school.ID#">#school.name#</option>
</cfoutput>
</select>


This is all I have. I don't know what to do from here. I know i need a second query, and a second drop down.
 
You've got two choices here.

1) you can write your own combination of CF code and cf generated javascript to perform the required function.

2) you can take a look at cf_twoselectesrelated (
if you want to do option one replay and we'll post code no doubt

Hope this helps!

Tony
 
Tony I'll take option one, thanks for posting the code.
 
To be honest the code that I would be posting here is all covered in GUJUm0deL's FAQ, so to save duplication on the forum, take a look at the code.

The basics of this are that you use CF to create the javascript for you, all of your data goes into the client side arrays and then you perform onchange events that then "decide" what information to put into the next drop down box

Hope this helps!

Tony
 
To avoid re-quering the dB over and over again you could cache the query results for an X amount of time. That's only advisable IF the query results do not change frequently. And, for heavy site traffic.

For example, if the dependable drop-down is for country and state then you can cache the query for X amount of time.

____________________________________
Just Imagine.
 
option 2, i am really not that versed in javascript, so i didnt understand it, but i got something figured out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top