We help IT Professionals succeed at work.

Related Select Dropdown

Medium Priority
134 Views
Last Modified: 2018-11-08
I need to create a set of dropdowns that are related to each other in coldfusion. The second dropdown should update itself based on what is selected in the first. Both will draw data from queries but from 2 separate data tables (cities and states). When the form finally submits, want to be able to retrieve id numbers from each dropdown

Have tried a number of coding variations with no luck
Comment
Watch Question

Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT

Commented:
long time not doing programming in coldfusion, but check this out:

ColdFusion Ajax Tutorial 2: Related Selects
http://forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects
Commented:
got it to work with the following code

 <p>Search for your business type </p>
      <p>
        <select name="select_category" required="yes" onChange="this.form.submit()">
        <option>Select Business Category</option>
        <cfloop query="get_business_categories">
          <option value="#categoryID#" <cfif IsDefined('form.select_category')>
            <cfif form.select_category eq "#categoryID#">selected</cfif></cfif>>#business_category#</option>
        </cfloop>
      </select>
      </p>
      <p>
<cfif IsDefined('page.select_category')>
     
     
      <!-- query db for the second time based on the prvious selection -->
        <cfquery name='get_business_areas' datasource='#conn#'>
select * from business_areas
where categoryID = #page.select_category#
</cfquery>
     
     
      <select name="select_area" required="yes">
      <option>Select Business Area</option>
      <cfloop query="get_business_areas">
            <option value="#areaID#">#business_type#</option>
      </cfloop>
      </select>
      <br>
      <br>
      <input type="submit" name="Submit" value="Select Branch">
</cfif>
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT

Commented:
yup, same concept, basically reading what is being posted for 1st dropdown and use it during the querying for 2nd dropdown.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.