JS: Storing dynamic variables across pages?

Posted by user2467599 on Stack Overflow See other posts from Stack Overflow or by user2467599
Published on 2013-06-27T04:17:45Z Indexed on 2013/06/27 4:21 UTC
Read the original article Hit count: 129

Filed under:
|
|

I've been looking into local storage options and plugins like Persist.js, sessvars.js, and even sisyphus.js - but I am unsure if any are the best fit (though I'm fairly certain I need to use one).

Page one is a form with input fields for data like names, phones, and email. I have a button that replicates a wrapper div (and it's inputs) as long as more inputs are needed. When the form is filled the user hits submit which takes them to a 'confirmation' type php page. I need to the give the user an 'edit' button on page 2 that takes them back to page 1 and leaves all the info alone.

For the most part everything returns fine, but if the user had hit the 'replicate' button before submission, and then hits edit afterwards, all the inputs that were dynamically generated return empty and the div no longer exists. Someone suggested that my variables are not persistent (when the replicate button is hit, input with an id="name1" becomes "name2" and so on) so that's when I found out about the plugins mentioned before.

Is there a way that I can implement one of those plugins (or any other method) so that when the user returns to page one the div and it's input values remain unchanged? And if I'm on the right track are there any examples?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery