我目前正在做一个ColdFusion (CF)项目,为我们的员工奖励网络应用程序添加功能。
我遇到的问题是,当返回到选择它的网页时,如何保持cfselect值。
当前,nomination.cfm使用子部门名称填充#1下拉菜单,这是从nomination.cfc函数getDept调用的。选择后,“nomination.cfc”将作为as参数传递给cffunction。
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})" />所有这些代码都在一个cfform中,然后提交给summary.cfm。在summary.cfm中有一个返回到nomination.cfm的编辑按钮。我用过
<input type="button" value=" Edit " onclick="history.go(-1);">但是#1和#2没有保留它选择的值,而是默认使用原始的下拉菜单列表。我在文档中读到cfc绑定不能做“选择”,所以我不知所措。提前感谢您的帮助!!
下面是nomination.cfc代码:
<!--- 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>发布于 2018-10-16 02:00:40
我有ColdFusion版本11,0,15,311399。
'selected‘属性在cfc绑定中的工作方式如下:
<cfselect selected="#Value#" name="Access_Level_Code_New"
size="1"
bind="cfc: APP_CFC.Example.GetAccessLevelSetRemote({Business_Area_Code_New},{System_Function_Code_New})"
bindonload="yes"
>我假设它也适用于较新的ColdFusion版本。
https://stackoverflow.com/questions/32734406
复制相似问题