简体   繁体   中英

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

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)

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM