dinger2121
Programmer
Hello,
I am attempting to create a set of cascading dropdown boxes using a component. I have the following code in my component.cfc -
And here are the boxes in the cfm file -
The problem that I am having is that the initial category drop down is not populating at all. I am not getting any error messages, so I have no idea what is missing. I know it is successfully hitting the functions in the cfc file because if I erroneously modify my query, it will produce the expected errors.
can anyone make a recommendation?
Thanks
carl
MCSD, MCTS:MOSS
I am attempting to create a set of cascading dropdown boxes using a component. I have the following code in my component.cfc -
Code:
<cfcomponent output="false">
<!--- Code for creating cascading drop down list for categories --->
<cfset THIS.dsn="inventory">
<!--- Get array of categories --->
<cffunction name="getCategory" access="remote" returnType="array">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT id,name
FROM category
GROUP BY name
ORDER BY name
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
<!--- Get subcategory by category --->
<cffunction name="getSubCategory" access="remote" returnType="array">
<cfargument name="categoryid" type="numeric" required="true">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT id,subcategory FROM category WHERE id = #ARGUMENTS.categoryid# ORDER BY artname
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.subcategory[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
<!--- END Code for creating cascading drop down list for categories --->
</cfcomponent>
And here are the boxes in the cfm file -
Code:
<tr>
<td align="right" nowrap><font size="-1"><B>Category:</B></font></td>
<td>
<cfselect name="categoryid" bind="cfc:category.getCategory()" bindonload="true">
<option name="0">--Select Category--</option>
</cfselect>
</td>
</tr>
<tr>
<td align="right" nowrap><font size="-1"><B>Sub-Category:</B></font></td>
<td>
<cfselect name="subcategoryid" bind="cfc:category.getSubCategory({categoryid})">
<option name="0">--Select Sub-Category--</option>
</cfselect>
</td>
</tr>
The problem that I am having is that the initial category drop down is not populating at all. I am not getting any error messages, so I have no idea what is missing. I know it is successfully hitting the functions in the cfc file because if I erroneously modify my query, it will produce the expected errors.
can anyone make a recommendation?
Thanks
carl
MCSD, MCTS:MOSS