Here is one you could use. It is not a custom tag, but not near as difficult
to format your html around it either. Just modify your queries etc...

<cfif isDefined('form.select_Main_Group')>
    <cfset page.select_Main_Group = form.select_Main_Group>
</cfif>
<cfoutput>
  <form name="DropDown" method="post">
  <!--- query DB for the first drop down list --->
  <cfquery name="get_Main_Group" datasource="xxx">
select categories.cat_id,
  categories.category,
  categories.parent_id
from categories
where categories.parent_id is null
  </cfquery>


  <!--- first drop down list --->
  <!--- NOTICE the onChange javascript event in the select tag, this is what
submits the form after the first selection --->
  <select name="select_Main_Group" required="yes"
onChange="this.form.submit()">
     <option></option>
     <!--- dynamically populate the first drop down list based on the
get_Main_Group query --->
     <!--- NOTICE the CFIF within the option tag, this says, if the first
selection has been made, display the chosen option when the page
reloads --->
     <cfloop query="get_Main_Group">
         <option value="#cat_id#" <cfif
isDefined("form.select_Main_Group")><cfif form.select_Main_Group eq
"#cat_id#">selected</cfif></cfif>>#category#</option>
     </cfloop>
</select>
<p>
<!--- if the first selection has been made, display the second drop down
list with the appropriate results --->
<cfif isDefined("page.select_Main_Group")>
   <!--- query DB for second drop down list, based on the selected item from
the first list --->
   <cfquery name="get_Sub_Group" datasource="xxx">
select  categories.cat_id,
   categories.category,
   categories.parent_id
from   categories
where  categories.parent_id = #form.select_Main_Group#
   </cfquery>


   <!--- second drop down list --->
   <select name="select_Sub_Group" required="yes"
onChange="this.form.submit()">
      <option>Select Subgroup</option>
      <!--- dynamically populate the second drop down list based on the
get_Sub_Group query --->
      <cfloop query="get_Sub_Group">
         <option value="#cat_id#" <cfif
isDefined("form.select_sub_group")><cfif form.select_sub_group eq
"#cat_id#">selected</cfif></cfif>>#category#</option>
      </cfloop>
   </select>
   </cfif>

</form>
</cfoutput>

----- Original Message ----- 
From: "Bobby Hartsfield" <[EMAIL PROTECTED]>
To: "CF-Talk" <cf-talk@houseoffusion.com>
Sent: Wednesday, September 06, 2006 2:21 PM
Subject: RE: dynamic related select box


> I like to write my own related selects but look for CF_TwoSelectsRelated
by
> Nate Weiss (there are also others that will relate more than 2 selects)
>
> ..:.:.:.:.:.:.:.:.:.:.:.:.
> Bobby Hartsfield
> http://acoderslife.com
>
>
>
>
>
>
> -----Original Message-----
> From: Ali Majdzadeh [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 06, 2006 3:03 PM
> To: CF-Talk
> Subject: dynamic related select box
>
> Hi everybody:
> I need a solution for dynamic related select box. For example when the
user
> selects the state in the other select box all the cities of the selected
> state appear.
> Do you any free/easy way to do that. I use coldfusion/ms access.
> Thanks
> Benign
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:252273
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to