I have a table that contains categories and unlimited subcategories
referencing and I need to create a formatted drop down list.  I've been
messin around with it for a while and now with no luck.  I need the list to
go like so...

Category Name
--Child of category
--Child of category
----Child of sub category
------Child of sub sub category
--Child of category

I can get the data out in the proper order, I just cant seem to get the --
in there.

I'm using this code as a custom tag which calls itself back again for the
recursion.

Thanks for the help
-emmet

<! --- // Calling the initial tag in the dropdown 
<SELECT name="parentID"
<cf_makedrop dsn=#dsn#>
</SELECT>

<! --- // now the tag makedrop.cfm

<cfsilent>
<cfparam name="Variables.ParentItemID" default="0">
<cfif IsDefined("Attributes.ParentItemID")>
        <cfset Variables.ParentItemID = Attributes.ParentItemID >
</cfif>

<CFQUERY NAME="GetCurrentCat" DATASOURCE="#attributes.dsn#">
SELECT      *
FROM         category
WHERE       ParentID = #Variables.ParentItemID#
ORDER BY    name
</CFQUERY>

</cfsilent>
<cfloop query="GetCurrentCat">
<cfoutput>
<OPTION value="#catID#" <cfif getcurrentCat.parentID is
0>class="lightcell"</cfif>>#GetCurrentCat.name#</OPTION>
</cfoutput>

<cfsilent>
<CFQUERY NAME="CheckForSub" DATASOURCE="#attributes.dsn#">
SELECT      *
FROM         category
WHERE       parentID = #GetCurrentCat.catID#
</CFQUERY>
</cfsilent>

<cfif CheckForSub.RecordCount gt 0 >
<cf_makedrop
                ParentItemID="#GetCurrentCat.catID#"
                dsn="#attributes.dsn#">
</cfif>
</cfloop>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184515
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to