jayst19143 0 Newbie Poster

I'm trying to dynamically populate a cfselect with a CFC using binding. Here's my cfc

<cfcomponent output="false">
   <!--- set function name --->
   <cffunction name="Get_Companies" access="remote" returnType="array">

      <!--- Define array to produce the drop down --->
      <cfset var data="">
      <cfset var result=ArrayNew(2)>
      <cfset var i=0>
      <!--- Get data --->
      <cfquery name="data" datasource="NewMediaIntranet">
      SELECT *
      FROM Companies
      Order by CompanyName
      </cfquery> 
      <!--- Convert results to array --->
      <cfloop index="i" from="1" to="#data.RecordCount#">
             <cfset result[i][1]=data.Company_ID[i]>
             <cfset result[i][2]=data.CompanyName[i]>      
             <!--- determine which is selected via what you passed and something in the database --->

      </cfloop>

      <!--- And return it --->
      <cfreturn result>

</cffunction>      
</cfcomponent>

And here's my cfm

<cfform name="myform">
<cfselect name="CompanyName" bindonload="true" bind="cfc:company.Get_Companies()" value="Company_ID" display="CompanyName"></cfselect>
</cfform>

Am I missing something?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.