Retain the form values in HTML even after re-directed from another HTML page

Viewed 114

I am creating a Sample Registration form using HTML and JS. After filling out all the fields in the form, I have a href link, on clicking it, takes to new HTMl page for uploading documents and on clicking a button in the upload page...it then re-directs to the form page. But the form page gets reloaded and so I am losing all the values given as input.

1 Answers

Here's one way you can do this :

In the JavaScript of the first HTML file (where you get the data):

localStorage.setItem('variable',value)

and then retrieve it from another JavaScript file:

localStorage.getItem('variable')

Another approach:

Global variables in Javascript across multiple files

Related