title: Persist variables between page loads
body: <p>I am trying to capture the submit button press of my form and if the form is submitted, the page refreshes and I show a few hidden fields. I would like to capture whether the form has been submitted before or not and if it submitted on reload, I would like to unhide the hidden fields. I was trying to use a global variable to achieve this, however I was unable to make it work properly.</p>
  
  <p>Here is what I tried:</p>
  
  <pre class="lang-js prettyprint-override"><code>  var clicked = false;
  
    $(document).ready(function() {
  
      $("input[type='submit'][value='Search']").attr("onclick", "form.act.value='detailSearch'; clicked = true;  return true;");
  
      if (clicked == true) {
        // show hidden fields
      } else {
        // don't show hidden fields
      }
    });
  </code></pre>
  
  <p>Any suggestions on what is wrong with this code?</p>