0

I have a ColdFusion 11 component which is supposed to populate a cfselect using bind. However, the select is not populated with the values at all. It shows blank. These are 2 select form controls that I want to relate to each other. A select from one should populate the other with values based on the selection made.

<td>
From IJ: 
      
<cfselect name="im" 
 id="im"
 bind="cfc:BTransfer.Get_Alls()"
 display="strTName"
 value="city_code"
 queryposition="below"
 bindonload="true">
 <option value="">Select ...</option>
</cfselect>
</td>   
     
<td> 
To IJ:     
<cfselect
    name="toij"
    id="toij"
 bind="cfc:BTransfer.Get_Ts({city_code})"
 value="strTCode"
 display="strTName"
 queryposition="below">
 <option value="">Select ...</option>
</cfselect>
</td>

[b]The component.[/b]

<cfcomponent output="false">

  <cffunction name="Get_Alls" access="remote" output="false" returntype="Query">

   <cfset var qry_getall = "">

   <CFQUERY NAME="qry_getall" DATASOURCE="#dsn#" cachedWithin="#CreateTimeSpan(1,0,0,0)#" >
   SELECT  T_Code AS strTCode,
   ltrim(t_name) AS strTName,
    city_code
   FROM  tblLookupTCity
   WHERE  blnactive = 1
   ORDER BY T_name
  </CFQUERY>
   <cfreturn qry_getall />
  
  </cffunction>

   <cffunction name="Get_Ts" access="remote" output="false" returntype="Query">

  <cfset var qry_getall = "">

  <cfargument name="city_code" type="numeric" required="true" >
  
   <CFQUERY NAME="qry_getall" DATASOURCE="#dsn#" cachedWithin="#CreateTimeSpan(1,0,0,0)#" >
    SELECT  T_Code AS strTCode,
    trim(T_name) AS strTName,
    city_code
    FROM  tblLookupTCity
    WHERE  CITY_CODE = '#arguments.city_code#'
      AND  blnactive = 1
    ORDER BY T_name
   </CFQUERY>

   <cfreturn qry_getall />

  </cffunction>

</cfcomponent>
kofboat123
  • 31
  • 1
  • 4
  • In your function Get_Ts, your first statement is CFSET. If CFARGUMENT is present it has to be first statement after the CFFUNCTION declaration. May be your component is throwing error due to this. – CFML_Developer Aug 11 '17 at 12:43
  • Getting your components to work with ColdFusion only before attempting to use them with ajax is a good idea. – Dan Bracuk Aug 11 '17 at 14:51
  • CFML_developer, I made those changes as suggested but it did work. I used the cfinvoke to call the function and it worked but for some strange reason when I bind it with the cfselect, no data shows. – kofboat123 Aug 13 '17 at 23:06

0 Answers0