title: JavaScript - Changing Boolean Value Using onClick on Button
body: <p>In here, I would wanna change the value of the input box. I would wanna change the value when user clicks on the <code>Save</code> button.</p>
  
  <p>For example, the default value of the input box is <code>False</code> but when user clicks on the save button, the value in the input box changes to <code>True</code>.</p>
  
  <p>Need help in solving the condition logic.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function change() 
  {
  
    var change = document.getElementById("check");
    if (change.value == "false") 
    {
      document.test.savereport = "True";
      document.test.submit();
    } 
    else 
    {
      change.value = "false";
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form name="test" method="post"&gt;
    &lt;input type="text" name="savereport" value="False" /&gt;
  &lt;/form&gt;
  
  &lt;div align="center"&gt;
    &lt;button type="button" value="false" id="check" onclick="change()" /&gt;Save&lt;/button&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>