Copy link to clipboard
Copied
Trying to use bind for two dependant select menus, category and subcategory, getting the error "Bind failed, element not found: T_categories_ID" it is driving me crazy:-)
The 'hic' is that I have to work with a CMS created by someone else, categories and subcategories are in the same table - oef-. Any help would be greatly appreciated. i keep having the impression this should actually be simple....
the form:
<cfform>
<table>
<tr>
<td>Select Media Type:</td>
<td><cfselect name="categoryid"
bind="cfc:cfc.getcategories.getcategories()"
bindonload="true" /></td>
</tr>
<tr>
<td>Select Art:</td>
<td><cfselect name="subcatid"
bind="cfc:cfc.getcategories.getsubcategories({T_categories_ID})" /></td>
</tr>
</table>
</cfform>
The cfc:
<cfcomponent output="false">
<!--- Get array of categories --->
<cffunction name="getcategories" access="remote" returnType="array">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data for categories --->
<cfquery name="data" datasource="#request.dba#">
SELECT T_categories_ID, T_categories_name
FROM T_categories
WHERE T_categories_partnerID = #session.partnerID# AND
T_categories_active = 1 AND
T_categories_ID > 0 AND
T_categories_name < > 'NULL'
ORDER BY T_categories_name
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[1]=data.T_categories_ID>
<cfset result[2]=data.T_categories_name>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
<!--- Get subcategories by media type --->
<cffunction name="getsubcategories" access="remote" returnType="array">
<cfargument name="T_categories_ID" type="numeric" required="true">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#request.dba#">
SELECT T_categories_subcat_ID, T_categories_subcat_name
FROM T_categories
WHERE T_categories_ID = #ARGUMENTS.T_categories_ID# AND
T_categories_partnerID = session.partnerID AND
T_categories_name = 'NULL' AND
T_categories_active = 1
ORDER BY T_categories_subcat_name
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[1]=data.T_categories_ID>
<cfset result[2]=data.T_categories_name>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
</cfcomponent>
In the second select, you wish to bind to the value of categoryid from the first select. Hence, that attribute should be:
bind="cfc:cfc.getcategories.getsubcategories({categoryid})"
Copy link to clipboard
Copied
In the second select, you wish to bind to the value of categoryid from the first select. Hence, that attribute should be:
bind="cfc:cfc.getcategories.getsubcategories({categoryid})"
Copy link to clipboard
Copied
error "*Bind failed, element
not found: T_categories_ID*" it is driving me crazy:-)
Think about it for a second ...;) If you want to bind to another form field, you need to use the form field "name" (or "id"). In your case it is "categoryid". You are accidentally using the function argument name instead ie "T_categories_ID".