Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help, don't understand bind

Guest
Jun 13, 2011 Jun 13, 2011

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>

605
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 13, 2011 Jun 13, 2011

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})"

Translate
Community Expert ,
Jun 13, 2011 Jun 13, 2011

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})"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 13, 2011 Jun 13, 2011
LATEST

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".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources