cf9 cfselect bind
janLynn_tn May 16, 2014 3:53 PMI have multiple dropdown lists on a form that are interdependent on each other. So, I'm using cfselects with binding based on selection of the previous drop down.
Here's the scenario:
Each 'sales representative' is assigned a number of clients. In turn, the clients are assigned a designated customer service rep.
I have a form that is using a cfselect to bind the clients displayed in the client list based on which sales representative is selected.
Once the 'client' is selected, I would like the next drop down list to populate with all customer service reps but have the rep that is actually assigned to the client be the default selected item in the drop down (e.g., selected="selected"). I need all service reps listed because there are instances that a case will be assigned to a different service rep than the default.
I have scoured the web and reviewed many examples but am still at a loss.
In my research found something similar to the code I'm using in the cfc (below) to pull the a list of all service reps and compare to see if the rep id is the client's designated rep.
<cfset result[i+1][3]=true> is being populated correctly, however this does not carry over to my cfselect to indicate the item selected.
Is there a different way I need to go about this?
Please ask if I'm not being clear in what I need this to do.
THANKS in advance for any assistance!
Code snippet:
<cffunction name="getSvcReps" access="remote" returnType="array">
<cfargument name="clientId" type="any" required="yes">
<cfargument name="dsn" type="any" required="yes">
<!---defines variables--->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<cfif not len(arguments.clientId)>
<cfset result[1][1]="">
<cfset result[1][2]="Please select a Client--->">
<cfreturn result>
<cfelse>
<cfquery datasource="#arguments.dsn#" name="svcReps">
SELECT
service_rep_id
,CONCAT(first," ",last) as svc_rep_name
FROM
svc_reps
</cfquery>
<cfquery datasource="#arguments.dsn#" name="defaultSvcRep">
SELECT
rep_id
FROM
client_reps
WERE
client_id ='#arguments.clientId#'
and rep_type="svc"
</cfquery>
<!---convert results to array--->
<cfset result[1][1]="">
<cfset result[1][2]="Select a Service Representative--->">
<cfset result[1][3]="">
<cfloop index="i" from = "1" to="#svcReps.recordCount#">
<cfset result[i+1][1]=svcReps.service_rep_id[i]>
<cfset result[i+1][2]=svcReps.svc_rep_name[i]>
<cfif svcReps.service_rep_id[i] EQ defaultSvcRep.rep_id>
<cfset result[i+1][3]=true>
<cfelse>
<cfset result[i+1][3]="">
</cfif>
</cfloop>
<cfreturn result>
</cfif>
</cffunction>

