Coldfusion 会话变量
我们有一个由查询动态填充的列表框。当我们在列表框中选择一个值并提交表单时,结果将显示在同一页面中。现在我们希望在以下情况下保留在列表框中选择的值:表格已提交。我们该如何处理?我们尝试使用以下代码在会话中设置变量: 会话:#session.sPcwQua#
现在我们如何使用列表框中设置的会话变量(在本例中为 session.sPcwQua),以便保留列表框中选定的值。
We have a list box which is getting dynamically populated by a query.When we are selecting a value in the list box and submitting the form the results are displayed in the same page.Now we want to retain the value selected in the list box when the form is submitted.How do we go about this? We have tried to set the variable in a session with the below code:
Session:#session.sPcwQua#
Now how do we use the session variable which is set that is in our case session.sPcwQua in the list box so that the selected value in the list box is retained.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能想使用表单范围而不是会话范围:
设置表单默认值:
运行查询:
填充选择框:
[可能需要检查其中的一些语法 - 因为我没有;t ;)]
-sean
You probably want to use the form scope rather than the session scope:
Set your form defaults:
run your query:
populate your selectbox:
[might have to check some of the syntax in there - cause I didn;t ;)]
-sean
如果您有特殊需要“保留值”并且想要设置 session.sPcwQua 变量,您可以尝试以下操作:
如果您只是尝试提交表单并返回元素值,那么您应该按照 Seasn 所说的操作:
If You have special need to "retain value" and you want to set the session.sPcwQua variable you can try this:
If You just trying to submit form and return element value than you should do what Seasn says: