简体   繁体   English

在浏览器中按回后如何保留下拉列表及其选择

[英]How to retain the dropdown and their selection after pressing back in browser

Having 2 dropdowns based on one drop down other will populate and open webpage. 根据一个下拉菜单中的另一个下拉菜单,有2个下拉菜单将填充并打开网页。 But when i press back in the webpage the 2nd dropdown is not seen. 但是,当我在网页中按回时,将看不到第二个下拉菜单。

The source below is the java code which i used. 下面的源是我使用的Java代码。 Please tell me how to use the location.hash property in this code to retain the dropdown. 请告诉我如何在此代码中使用location.hash属性来保留下拉列表。

I tried using the location.hash and location.href but it's not working. 我尝试使用location.hash和location.href,但无法正常工作。 Please help me resolve my problem. 请帮助我解决我的问题。

<script language="javascript">
    var selectmenu=document.getElementById("mymenu")
    selectmenu.onchange=function()
    {
       var chosenoption=this.options[this.selectedIndex]
       if (chosenoption.value!="nothing")
       {
          window.open(chosenoption.value,"_parent")
       }
    }
</script>

I would say, the design not very good. 我会说,设计不是很好。

  1. When the dropdown value is changed (say on Page A), call a server side action listener (or a simple servlet, may be by simply submitting the form). 当下拉值更改时(例如,在页面A上),请调用服务器端操作侦听器(或简单的servlet,可能只需提交表单即可)。
  2. Then let the server redirect (or forward) to next page (say Page B). 然后,让服务器重定向(或转发)到下一页(例如B页)。 In this process you will get a chance to save the submitted value. 在此过程中,您将有机会保存提交的值。 You can save the submitted value in the session. 您可以将提交的值保存在会话中。
  3. While rendering Page A, check if any value is present in the session. 呈现Page A时,请检查会话中是否存在任何值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在重新启动,按回并更改方向后保留android app imageButton的onClick状态 - How to retain an android app imageButton's onClick state after restarting, pressing back and changinging orientation 我如何保留我的下拉选择 - how can i retain my dropdown selection 浏览器关闭后如何保留会话? - How to retain session after browser close? 按下添加按钮后如何从单选按钮恢复选择 - How to revert selection from radio button after pressing add button 按下后退按钮后防止重新提交表单 - Prevent form resubmit after pressing back button 按下后退按钮后会话不会破坏 - After pressing back button session doesnot destroy 如果从下拉列表中进行选择,如何将if语句放置在后面 - how do I place an if statement after a selection if made from dropdown 如何防止用户“退回”但在JSP注销后保留缓存? - How do I prevent users from going 'back' but retain the cache after a logout in JSP? 在Android中按下返回首页后如何重新启动主要活动 - How to re-launch main activity after pressing back to go to home in Android go 如何通过按下带有一些数据的后退按钮返回上一个活动? - How to go back to the previous activity by pressing the back button with some data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM