How to store form data in javascript for history use in another page or reopen page

北城以北 提交于 2019-12-12 03:22:01

问题


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)


回答1:


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.




回答2:


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



回答3:


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



回答4:


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.



来源:https://stackoverflow.com/questions/9327776/how-to-store-form-data-in-javascript-for-history-use-in-another-page-or-reopen-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!