如何在javascript中存储表单数据以便在另一个页面或重新打开页面中使用历史记录

发布于 2025-01-06 17:54:04 字数 156 浏览 6 评论 0原文

我想要 jsp 或 javascript 来保存表单数据以供历史记录 - 没有cookies - 没有会话 没有数据库

-当您打开表格、填写表格、提交表格时 ... 有时用户必须返回表单进行一些更改...... 表单的所有字段都会自动填充旧数据...(因为表单中有 28 个字段)

i want jsp or javascript for save form data for history
-no cookies
-no session
-no database

when your open form, fill form, submit form...
some time user have to come back on form for some change...
all field of form with auto fill with old data...(because 28 fields in form)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱的那么颓废 2025-01-13 17:54:04

如果您使用的是 HTML 5。您可以使用 HTML5 的本地存储。

localStorage.setItem("name", "Hello World!"); //saves to the database, key/value
document.write(localStorage.getItem("name")); //Hello World!
localStorage.removeItem("name"); //deletes the matching item from the database

If you are using HTML 5. You can employ HTML5's Local Storage.

localStorage.setItem("name", "Hello World!"); //saves to the database, key/value
document.write(localStorage.getItem("name")); //Hello World!
localStorage.removeItem("name"); //deletes the matching item from the database
十二 2025-01-13 17:54:04

然后就可以使用HTML5了。因为有一个工具可以存储临时数据,并且您也可以将该数据放入其他页面中。

像这样 :

localStorage.setItem("key1", "Value1"); //saves to the database, key/value    
document.write(localStorage.getItem("key1")); //Will print value  of key1
localStorage.removeItem("key1"); //deletes the matching item from the database

Then you can use HTML5. Because there is a facility to store the temporally data and you can get that data into other pages also .

Like this :

localStorage.setItem("key1", "Value1"); //saves to the database, key/value    
document.write(localStorage.getItem("key1")); //Will print value  of key1
localStorage.removeItem("key1"); //deletes the matching item from the database
彻夜缠绵 2025-01-13 17:54:04

如果没有某种身份验证,您就无法跟踪用户/访问者,这可能需要会话/cookie(和数据库)。

关闭页面/浏览器会结束会话,但 cookie 和 localStorage 是持久的。

序列化表单并使用localStorage 保存它。

You can´t track users/visitors without some kind of authentication and that might require sessions/cookies (and databases).

Closing the page/browser ends the session but cookies and localStorage are persistent.

Serialize the form and the use localStorage to save it.

独闯女儿国 2025-01-13 17:54:04

(据我所知)使用浏览器历史记录存储是不可能的。您也不希望它成为可能,因为这意味着使用同一浏览器的其他人可以使用后退按钮来获取用户所有可能的机密数据。

如果您确实必须这样做,正确的方法是使用 cookie 来跟踪用户的会话,如果他们已登录(而不是其他情况),则使用他们登录的信息预先填写服务器上表单的 HTML上次输入数据库。

This is (as far as I am aware) not possible using browser history storage. You would also not want it to be possible, as it means that other people using the same browser could use the back button to get to all of the user's possibly confidential data.

The right way to do this, if you really must, is to use cookies to keep track of the user's session and if they are logged in (and not otherwise), pre-fill the HTML of the form on the server with the information they entered into the database last time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文