• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

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.
0
akali
Asked:
akali
  • 2
1 Solution
 
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now