4 Dynamic Drop downs

I have 4 drop downs boxes that  I would like to populate based on the preceding drop down selection. Since the volume of data is large I would like to make a trip to the database each time a selection is made.
My criteria is Campus, building, floors and rooms.

Any help would be appreciated.
akaliAsked:
Who is Participating?
 
mrichmonCommented:
If you want to go to the database each time then very easy.

A combination of javascript and CF will give the best interface :

<form method="post" action="thispage.cfm" name="MyForm">

<select name="Campus" onChange="document.MyForm.submit();">
   <cfoutput query="GetCampuses"><option value="#id#">#CampusName#</option></cfquery>
</select>

<select name="Building" onChange="document.MyForm.submit();">
<cfif IsDefined("Form.Campus")>
   <cfoutput query="GetBuildings"><option value="#id#">#buildingName#</option></cfquery>
</cfif>
</select>

<select name="Floor" onChange="document.MyForm.submit();">
<cfif IsDefined("Form.Building")>
   <cfoutput query="GetFloors"><option value="#id#">#FloorName#</option></cfquery>
</cfif>
</select>

<select name="Room" onChange="document.MyForm.submit();">
<cfif IsDefined("Form.Floor")>
   <cfoutput query="GetRooms"><option value="#id#">#roomNumber#</option></cfquery>
</cfif>
</select>

</form>
0
 
mrichmonCommented:
Oh you also have to have the queries at the top of the page defined for GetCampuses, GetBuildings, GetFloors, GetRooms

Like this:

<cfquery datasource="yourdsn" name="GetCampuses">
SELECT * FROM Campus
</cfquery>

<cfif IsDefined("Form.Campus")>
<cfquery datasource="yourdsn" name="GetBuildings">
SELECT * FROM Buildings WHERE CampusID = #Form.Campus#
</cfquery>
</cfif>

<cfif IsDefined("Form.Building")>
<cfquery datasource="yourdsn" name="GetFloors">
SELECT * FROM Floors WHERE BuildingID = #Form.Building#
</cfquery>
</cfif>

<cfif IsDefined("Form.Floor")>
<cfquery datasource="yourdsn" name="GetRooms">
SELECT * FROM ROoms WHERE FloorID= #Form.Floor#
</cfquery>
</cfif>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.