使用 CFQUERY 和 CFSELECT 根据选择提取多个值
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的(就尽可能少的代码更改而言)是:
然后使用
ListFirst(FORM.getSubTurf)
和ListLast(FORM.getSubTurf)
。另外,不要忘记使用
。Simplest (in terms of littlest-possible code change) would be to do:
And then use
ListFirst(FORM.getSubTurf)
andListLast(FORM.getSubTurf)
. Also, don't forget to use<cfqueryparam>
.要跨页面维护查询结果,您必须拆分返回到表单操作页面的值...这是建议的答案...
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.***)#>