使用CFQUERY和CFSELECT基于选择提取多个值 [英] Using CFQUERY and CFSELECT to pull multiple values based on selection

查看:102
本文介绍了使用CFQUERY和CFSELECT基于选择提取多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CFQUERY拉三列。以下CFSELECT允许用户基于 display参数从各种结果中进行选择,并将值设置为 value参数。

I have a CFQUERY pulling three columns. The following CFSELECT allows the user to make a selection from various results based on the 'display' parameter, and sets the value to the 'value' parameter.

我想将该记录的第三个未使用的值传递给一个变量,以便在以后的查询中使用。我无法将值字段设置为所需的列,因为在此查询之后的查询中需要该值(查询根据先前的下拉选择进行填充)。

I would like to pass the third unused value of that record to a variable to be used in a later query. I cannot set the 'value' field to the column I need since that value is needed in a query following this one (queries populate based on previous drop down selections).

有没有办法做到这一点? CFSELECT是否以某种方式获取2个单独的值?

Is there a way to do this? To somehow have the CFSELECT grab 2 separate values?

SubRegionName 显示。

SubRegionCD 用于对此选择,以后需要。

SubRegionCD for this selection made is needed later.

下面的代码示例:

    <cfquery name="qrySubTurf"
 DATASOURCESTUFF>
 SELECT SubRegionName, SubRegionCd, State
 From dbo.tblRegions 
 where Region='#form.getRegion#'  <!---Previous CFSELCT value--->
 order by SubRegionName
     </cfquery>

     <cfselect name="getSubTurf"
 style="width:220px"
 size=1
 multiple="no"
 query="qrySubTurf"
 value="state"                   <!---Value passed to the next CFQUERY--->
 display="SubRegionName"         <!---Value displayed to user--->
 queryPosition="below"
 onChange="AddForm.submit();">
        <option value=""></option>
     </cfselect>

现在我需要抓取与用户选择State和SubRegionName相关联的SubRegionCD并将其分配给可以在最终查询中使用的变量。我不能仅使用State来确定SubRegionCD,但是可以使用SubRegionName进行1-1匹配。

Now I need to grab the SubRegionCD associated with the users selection of State and SubRegionName and assign it to a variable that can be used in the final query. I cannot use State alone to determine the SubRegionCD, but I CAN use SubRegionName to make a 1-1 match. Help?

推荐答案

最简单的方法(就最小的代码更改而言)就是:

Simplest (in terms of littlest-possible code change) would be to do:

<cfquery name="qrySubTurf"
 DATASOURCESTUFF>
 SELECT SubRegionName, SubRegionCd + ',' + State AS Key
 From dbo.tblRegions 
 where Region=<cfqueryparam value="#form.getRegion#" cfsqltype="CF_SQL_VARCHAR">
 order by SubRegionName
</cfquery>

<cfselect name="getSubTurf"
 style="width:220px"
 size=1
 multiple="no"
 query="qrySubTurf"
 value="Key"
 display="SubRegionName"
 queryPosition="below"
 onChange="AddForm.submit();">
  <option value=""></option>
</cfselect>

然后使用 ListFirst(FORM.getSubTurf) ListLast(FORM.getSubTurf)。另外,不要忘记使用< cfqueryparam>

And then use ListFirst(FORM.getSubTurf) and ListLast(FORM.getSubTurf). Also, don't forget to use <cfqueryparam>.

这篇关于使用CFQUERY和CFSELECT基于选择提取多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆