刷新时保留下拉选择 [英] retain dropdown selection on refresh
问题描述
可能的重复:
在回发时保留选定的下拉选项
当用户选择选项时,我有一个下拉列表,该值被传递到与刷新页面的查询字符串相同的 url.页面刷新后,我想保留选定的值,以便用户知道选择了什么.我如何在 jquery 中做到这一点?
I have a dropdown when user selects the option, the value is passed on to the same url as querystring refreshing the page. after the page refreshes i wanna retain the selected value so user knows what was selected. How do i do this in jquery?
<select id="hospitalDropDown" onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="http://mysite.com/events/Pages/default1.aspx">All Hospitals</option>
<option value="http://mysite.com/events/Pages/default1.aspx?hos=Dyer">Dyer</option>
<option value="http://mysite.com/events/Pages/default1.aspx?hos=Carmel">Carmel</option>
</select>
基本上逻辑是将选择捕获在某个变量中并将其作为 selected 等于 true 传递,但我无法在 jquery 中执行此操作..我无法访问服务器端代码..要么
Basically the logic is trap the selection in some variable and pass it as selected equals true but i am not being able to do it in jquery..I don't have acccess to server side code..either
推荐答案
对于一个干净的方法,你可以设置一个 cookie
For a clean method you can set a cookie
看看下面的问题和回复
*但我最喜欢的是使用 ajax 方法在用户会话中设置选择.
*But my favorite is to set the selection in the user session using ajax method.
这篇关于刷新时保留下拉选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!