title: HTML5 localStorage Perform Action on Checkbox
body: <p>Following the tutorial here, <a href="http://css-tricks.com/video-screencasts/96-localstorage-for-forms/" rel="nofollow">http://css-tricks.com/video-screencasts/96-localstorage-for-forms/</a>. I was able to recreate the functionality with the submit buttons, however, instead of the buttons, is it possible to use checkboxes instead?</p>
  
  <p>Here's what I have so far, </p>
  
  <pre><code>if (localStorage) {
  
  $(function() {
  
      // Insert new buttons
      $("#savelinks")
          .after("&lt;input type='submit' value='Save Address' id='saveData'&gt; &amp;nbsp;&amp;nbsp;")
          .after("&lt;input type='submit' value='Clear Saved Address' id='clearData'&gt;");
  
      $("#saveData")
          .click(function(e) {
  
                      e.preventDefault();
                      // Test if saved data exists on page load
                      localStorage.setItem("flag", "set");
                      var data = $("#form1").serializeArray();
  
                      // iterate over results
                      $.each(data, function(i, obj) {
  
                                     localStorage.setItem(obj.name, obj.value);
  
                       });
  
          });
  
  
  
      if (localStorage.getItem("flag") == "set") {
          var data = $("#form1").serializeArray();
          $.each(data, function(i, obj) {
              $("[name='" + obj.name +"']").val(localStorage.getItem(obj.name));
          });
      }   
  
  
  
      $("#clearData")
          .click(function(e) {
              e.preventDefault();
              localStorage.setItem("flag", "");
          });
  });
  }
  </code></pre>
  
  <p>Thank you in advance!</p>