Im working on using HTML5 persistent storage on an existing application used for the purpose of surveys.
What I need to now do, is pass a variable through to the final “completed” page, which I can then use to remove the persistant object that I have saved in the mobile devices memory.
Any ideas how I can do this?
Currently, the submit button is set up like this.
<input type='submit' value='Submit' onclick="saveData(); surveyfunction();"/>
The saveData() function, is my function, (adds values to array then makes a unique object e.t.c, the surveyfunction is the survey softwares function for physically submitting the data.
Any ideas greatly appreciated – thanks!
Use localStorage.get/setItem. This worked when I tested it locally:
(test.html)
(test2.html)
You’ll want to test for local storage support using Modernizr or something.
UPDATE:
You can either persist it to a cookie or local storage. Local storage is probably preferable, but there’s no reason you can’t come up with a very detailed naming convention for it.
Why can’t you set the SID in a cookie? With cookies, you can set the path that the cookie is visible to as part of the cookie’s configuration. That means if you have /survey1 and /servey2 on your server, you can set two separate cookies each with their own SID value.