Question
How do you display certain fields in a bind to cfselect?
I have 2 cfselects that bind to a couple of queries. In the
first query I select a location code and a location name. In the
actual cfselect I want to display #Location# - #LocName# in that
format but it is only showing whatever is in the second slot of my
array. Here is my .cfc code:
<cffunction name="getLocation" access="remote" returnType="array">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT Location, LocName
FROM Locations
ORDER BY Location ASC
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result [1]=data.Location>
<cfset result [2]=data.LocName>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
<cffunction name="getController" access="remote" returnType="array">
<cfargument name="controller" required="no" type="any">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT PartsInventory.Location, PartsInventory.Controller, PartsInventory.SerialNbr, PartsInventory.Model, Locations.CX
FROM PartsInventory LEFT JOIN Locations ON PartsInventory.Location = Locations.Location
WHERE PartsInventory.Location = ('#ARGUMENTS.controller#')
Order By PartsInventory.Controller ASC
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result [1]=data.SerialNbr>
<cfset result [2]=data.Controller>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
Here is my select boxes:
<cfselect name="bldglocation" bind="cfc:controllerselect.getLocation()" bindonload="true" />
<cfselect enabled="No" name="getController" multiple="no" style="width: 21em;"
bind="cfc:controllerselect.getController({bldglocation})" bindonload="false" />
They are getting the right information I just do not know how to make a form object display certain items from my query.
Any ideas are appreciated.
Thanks.
<cffunction name="getLocation" access="remote" returnType="array">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT Location, LocName
FROM Locations
ORDER BY Location ASC
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result [1]=data.Location>
<cfset result [2]=data.LocName>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
<cffunction name="getController" access="remote" returnType="array">
<cfargument name="controller" required="no" type="any">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="#THIS.dsn#">
SELECT PartsInventory.Location, PartsInventory.Controller, PartsInventory.SerialNbr, PartsInventory.Model, Locations.CX
FROM PartsInventory LEFT JOIN Locations ON PartsInventory.Location = Locations.Location
WHERE PartsInventory.Location = ('#ARGUMENTS.controller#')
Order By PartsInventory.Controller ASC
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result [1]=data.SerialNbr>
<cfset result [2]=data.Controller>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
Here is my select boxes:
<cfselect name="bldglocation" bind="cfc:controllerselect.getLocation()" bindonload="true" />
<cfselect enabled="No" name="getController" multiple="no" style="width: 21em;"
bind="cfc:controllerselect.getController({bldglocation})" bindonload="false" />
They are getting the right information I just do not know how to make a form object display certain items from my query.
Any ideas are appreciated.
Thanks.
