0 Replies Latest reply: Feb 11, 2009 9:56 AM by kodemonki RSS

    Succeeding CFSELECT not binding correctly

    kodemonki Community Member
      I've searched the web, and a number of awesome tutorials, but I keep getting stuck on my bind failing, but I can't figure out why! I am using the name of the preceeding cfselect for the current method argument, I've checked that both cfselects work correctly when the second does not depend on the first. It looks like the binding happens AFTER the error, which I'm not sure how to fix. And it also looks like it's binding to all the data returned from the first cfselect call, instead of just the default selected id. If anyone can show me the error of my ways, I'd very much appreciate it!

      [code]
      .cfm
      <cfselect name="type_id" bind="cfc:calls.call_types()" bindOnLoad="true" />
      <cfselect name="concern_id" bind="cfc:calls.get_concerns({type_id})" />

      calls.cfc
      <cfcomponent>
      <cfset dsn = 'admi-prod'>
      <!--- get types of calls --->
      <cffunction name="call_types" access="remote" returntype="array">
      <cfset var result = arrayNew(2)>
      <cfset var data = querynew("concern_type, type_id")>
      <cfcontent type="text/html" reset="yes">
      <cfset queryAddRow(data)>
      <cfset querySetCell(data,"concern_type", "Special Projects")>
      <cfset querySetCell(data, "type_id", 16)>
      <cfset queryAddRow(data)>
      <cfset querySetCell(data,"concern_type", "QA")>
      <cfset querySetCell(data, "type_id", 36)>
      <cfquery name="data2" dbtype="query">
      SELECT concern_type, type_id
      FROM data
      </cfquery>
      <cfloop index="i" from="1" to="#data2.RecordCount#">
      <cfset result [1] = data2.type_id>
      <cfset result [2] = data2.concern_type>
      </cfloop>
      <cfreturn result>
      </cffunction>
      <cffunction name="get_concerns" access="remote" returntype="array">
      <cfargument name="type_id" type="numeric" required="yes">
      <cfset var data = "">
      <cfset var result = arrayNew(2)>
      <cfset var i = 0>
      <cfquery name="data" datasource="#dsn#">
      SELECT concern, concern_id
      FROM pbr_concerns_masters
      WHERE concern_type = #arguments.type_id#
      ORDER BY concern
      </cfquery>
      <cfloop index="i" from="1" to="#data.RecordCount#">
      <cfset result [1] = data.concern_id>
      <cfset result [2] = data.concern>
      </cfloop>
      <cfreturn result>
      </cffunction>
      </cfcomponent>

      cfdebug:
      info:bind: Assigned bind value: '16,Special Projects,36,QA' to type_id.value
      info:http: CFC invocation response: [[16,"Special Projects"],[36,"QA"]]
      error:bind: Bind failed, element not found: type_id
      [/code]