首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何保持cfselect的cfselect绑定选定值

如何保持cfselect的cfselect绑定选定值
EN

Stack Overflow用户
提问于 2015-09-23 16:20:10
回答 1查看 1.2K关注 0票数 1

我目前正在做一个ColdFusion (CF)项目,为我们的员工奖励网络应用程序添加功能。

我遇到的问题是,当返回到选择它的网页时,如何保持cfselect值。

当前,nomination.cfm使用子部门名称填充#1下拉菜单,这是从nomination.cfc函数getDept调用的。选择后,“nomination.cfc”将作为as参数传递给cffunction。

代码语言:javascript
复制
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的编辑按钮。我用过

代码语言:javascript
复制
<input type="button" value="    Edit   " onclick="history.go(-1);">

但是#1和#2没有保留它选择的值,而是默认使用原始的下拉菜单列表。我在文档中读到cfc绑定不能做“选择”,所以我不知所措。提前感谢您的帮助!!

下面是nomination.cfc代码:

代码语言:javascript
复制
    <!--- 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>
EN

回答 1

Stack Overflow用户

发布于 2018-10-16 02:00:40

我有ColdFusion版本11,0,15,311399。

'selected‘属性在cfc绑定中的工作方式如下:

代码语言:javascript
复制
<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版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32734406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档