title: How do you store the value of a checked radio button in local storage using pure Javascript?
body: <p>I'd like to store my checked radio button in local storage so that on a page reload it will have the last checked item check on the reload.</p>
  
  <p>Html:</p>
  
  <pre><code>&lt;h3&gt;Seconds Display:&lt;/h3&gt;
  &lt;p id="secondsHidingText"&gt;Hiding seconds extends battery life&lt;/p&gt;
  &amp;nbsp&amp;nbsp&lt;input type="radio" name="seconds" value="show" checked="checked"&gt;Show&amp;nbsp&amp;nbsp
  &lt;input type="radio" name="seconds" value="hide"&gt;Hide
  </code></pre>
  
  <p>This is the javascript I have:</p>
  
  <pre><code>localStorage.setItem('seconds', options.seconds);
  </code></pre>
  
  <p>(which runs when the save button I have is clicked)</p>
  
  <p>And</p>
  
  <pre><code>document.getElementById('seconds').value = localStorage.getItem("seconds");
  </code></pre>
  
  <p>(which runs on document being loaded)</p>
  
  <p>I get the following error: <code>Uncaught TypeError: Cannot set property 'value' of null</code></p>
  
  <p>How do I store and retrieve the checked radio button to and from local storage?  And if possible I'm looking for a pure JS way of accomplishing this.</p>
  
  <p>Thanks!</p>