在刷新时保留下拉列表选择 [英] 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>
基本上,逻辑是在一些变量中隐藏选择,并将其作为选择等于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屋!