Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to populate a form from form data stored in localStorage?
    primarykey
    data
    text
    <p>So I have this js file to store form data in local storage:</p> <pre><code>$(document).on('pageinit', function() { // dom ready handler for jQuery Mobile $('#form1').validate({ // initialize form 1 // rules }); $('#gotoStep2').on('click', function() { // go to step 2 if ($('#form1').valid()) { // code to reveal step 2 and hide step 1 } }); $('#form2').validate({ // initialize form 2 // rules }); $('#gotoStep3').on('click', function() { // go to step 3 if ($('#form2').valid()) { // code to reveal step 3 and hide step 2 } }); $('#form3').validate({ initialize form 3 // rules, submitHandler: function (form) { // serialize and join data for all forms var data = $('#form1').serialize() + '&amp;' + $('#form2').serialize() + '&amp;' + $(form).serialize(); window.localStorage.setItem('formData',data); // ajax submit return false; // block regular form submit action } }); // there is no third click handler since the plugin takes care of this // with the built-in submitHandler callback function on the last form. }); </code></pre> <p>It does the job, but I have no idea how to retrieve that information back to prepopulate the form if the user enters to the site to verify if the data is correct in their respective fields. I know how to do it if the fields are stored individually but I don't know how to do it if it's serialize like the example.</p> <p>A working <a href="http://jsfiddle.net/Ch32k0/HUNPp/" rel="nofollow">example</a> made by Sparky, I just added <code>window.localStorage(...)</code></p> <p>BTW: There're over 100 fields not just 3 as in the example.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload