Assuming you don't want to set up a server to store this info, you're left with only a few options here. Specifically, client-side storage. I'll cover localStorage
as it's the easiest to use and you've mentioned it above.
Here's the localStorage API. If you believe that the interface is too complicated, I would recommend giving it a read through, perhaps along with a tutorial (Personally I believe the Mozilla Docs to be better but this tut looks more applicable for your application).
In short, you will be making use of the setItem(...)
and getItem(...)
methods.
localStorage.setItem("My test key", "My test value");
console.log(localStorage.getItem("My test key")); // --> My test value
So, for your application, I would recommend creating an object to store your values in and then appending said object to localStorage
.
var state = {}
// Get values from your form however you feel fit
values = getValues(...);
function setValues(values) {
// Do this for all the values you want to save
state.values = values
// Continues for other values you want to set...
}
// Save values to localStorage
localStorage.setItem("Application_State", state);
Now for retrieving state when the user comes back your website.
// Application_State is null if we have not set the state before
var state = localStorage.getItem("Application_State") || {};
function updateValues() {
values = state.values;
// Render your values to the UI however you see fit
}
This is a very brief intro here and I would encourage you to carefully read the docs on this stuff before publishing it to a production-ready site.
Hope this helps && good luck!