prakash g
prakash g

Reputation: 49

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

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.

Upvotes: 4

Views: 250

Answers (1)

ssomename
ssomename

Reputation: 545

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

Upvotes: 2

Related Questions