在事件window.history.back() - JavaScript中保留动态创建的DropDown列表的选定值 [英] Retain dynamically created DropDown list's selected value on event window.history.back()- JavaScript

查看:338
本文介绍了在事件window.history.back() - JavaScript中保留动态创建的DropDown列表的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用以下问题作为参考来解释上下文:
根据另一个选择填充一个下拉菜单

Can use the below question as a reference to explain the context: Populate one dropdown based on selection in another

在我的页面上;在从下拉列表中选择适当的值并填写几个文本字段后,用户将提交表单。

On my page; after selecting the proper values from the dropdown lists and filling up a few text fields, the user submits the form.

下一页用于确认,请求用户他/她是否想编辑表单。编辑按钮只是将用户恢复到上一页(window.history.back())。

The next page is for the confirmation, that asks the user whether he/she wants to edit the form.The edit button just takes back the user to the previous page (window.history.back()).

现在的问题是,页面上的每个字段都保留了用户填写的值。除了第二个下拉列表(从属下拉列表)。

Now the problem is, every field on the page has retained the value that was filled by the user. Except the second dropdown list (dependent dropdown list).

有没有办法解决这个问题?

Is there a way to fix this?

推荐答案

没有特定代码的上下文,很难很好地回答,但您应该使用 window.sessionStorage或window.localStorage 临时存储javascript中的页面之间的持久性数据。

Without the context of your specific code, it's hard to answer well, but you should look into using the window.sessionStorage or window.localStorage to temporarily store data for persistence between pages in javascript.

这篇关于在事件window.history.back() - JavaScript中保留动态创建的DropDown列表的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆