使用 CFQUERY 和 CFSELECT 根据选择提取多个值

发布于 2024-10-13 06:25:13 字数 1159 浏览 7 评论 0原文

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

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

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

显示SubRegionName

状态是要传递的值。

稍后需要为选择SubRegionCD

下面的代码示例:

    <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 匹配。帮助?

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).

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

SubRegionName is Displayed.

State is the value to pass.

SubRegionCD for this selection made is needed later.

Code example below:

    <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>

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怎樣才叫好 2024-10-20 06:25:13

最简单的(就尽可能少的代码更改而言)是:

<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)。另外,不要忘记使用

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>

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

污味仙女 2024-10-20 06:25:13

要跨页面维护查询结果,您必须拆分返回到表单操作页面的值...这是建议的答案...

To maintain the query result across pages you have to split the value returned to the form's action page ... this is was the answer suggested ... <cfqueryparam value ="#ListFirst(form.***)#>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文