I currently working on a ColdFusion (CF) project adding features to our employee appreciation award web app.
The problem I am having is how to keep the cfselect value when returning to the web page where it was selected.
Currently the nomination.cfm populates #1 drop down menu with the sub-departments names, and that is called from nomination.cfc cffunction getDept. Once that is selected then "department" passed to nomination.cfc cffunction getEmp as a cfargument.
1. Select the location where your nominee works:
<cfselect name="department" bind="cfc:nominee.getDept ()" bindonload="true" />
2. Select the nominee from the list below
<cfselect name="employee" bind="cfc:nominee.getEmp ({department})" />
All this code is inside a cfform where is it submitted to summary.cfm. In summary.cfm there's an edit button that goes back to the nomination.cfm. I used
<input type="button" value=" Edit " onclick="history.go(-1);">
But #1 and #2 did not kept its selected values, instead defaulted to the original drop down menu listing. I read in docs that cfc binding can not do "selected", so I am at a loss. Thanks in advance for your help!!
Here below is the nomination.cfc codes:
<!--- Get array of media types --->
<cffunction name="getDept" access="remote" returnType="array">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="HatsOff">
SELECT account_number, account_title
FROM departments
<cfif session.vdept is not "All" and session.vdept is not "Letter">
WHERE [departmentname] = '#session.vdept#'
</cfif>
ORDER BY account_title
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.account_number[i]>
<cfset result[i][2]=data.account_title[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
<!--- Get art by media type --->
<cffunction name="getEmp" access="remote" returnType="array">
<cfargument name="department" type="string" required="true">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="HatsOff">
SELECT emp_id, emp_full_name
FROM employees
WHERE account_number = '#ARGUMENTS.department#'
ORDER BY emp_full_name
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.emp_id[i]>
<cfset result[i][2]=data.emp_full_name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
</cfcomponent>