title: Create enable and disable button in PHP
body: <p>I have two buttons which are the submit button and save button. </p>
  
  <p>The first time the page loads, the submit button should be enabled while the save button should be disabled.</p>
  
  <p>After the submit button is clicked, the submit button should be disabled and record will be display while the save button should be enabled so that I can save record. But I cant enable the save button after the submit button is clicked and the record is displayed.</p>
  
  <h3>HTML</h3>
  
  <pre class="lang-html prettyprint-override"><code>&lt;header&gt;&lt;h4&gt;Customer Purchase Order&lt;/h4&gt;&lt;/header&gt;
  &lt;form action="" method="post" class="form-disable"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="global.js"&gt;&lt;/script&gt;
  &lt;table style="border-collapse:collapse;" width="1400px" height="172px" border="1"&gt;
          Delivery Date:&amp;nbsp;&amp;nbsp;&lt;input type="text" name="sdate2" placeholder="yyyy-mm-dd" onkeypress="return noenter()"&gt;
          Date:&amp;nbsp;&amp;nbsp;&lt;input type="text" name="sdate" placeholder="yyyy-mm-dd" value="" onkeypress="return noenter()"&gt;&amp;nbsp;&amp;nbsp;
          &lt;input type="button" class="but" name="sub" id="sub" value="Submit" formaction="" style="WIDTH: 57px; HEIGHT: 31px;" onkeypress="return noenter()" onclick="myFunction()"&gt;
          &lt;input type="button" class="but" name="save" id="save" value="Save" disabled formaction="addorder1.php" style="WIDTH: 57px; HEIGHT: 31px;" onkeypress="return noenter()" onclick="myFunction()"&gt;&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  
  
  <h3>JAVASCRIPT</h3>
  
  
  
  <pre class="lang-js prettyprint-override"><code>$(function() 
  {
    $(".but").on("click", function(e) 
    {
      e.preventDefault(); // not really necessary if buttons
      $(this).prop("disabled", true);    
      if (this.id=="sub") 
      {
        // do the submit and enable other button
        $("#save").prop("disabled", false);
      }
      else 
      {
        // do the save and enable other button
        $("#sub").prop("disabled", false);
      }
    });
  });
  </code></pre>
  
  <h3>Demo</h3>
  
  <p><a href="https://jsfiddle.net/kk5wxm37/" rel="nofollow noreferrer">https://jsfiddle.net/kk5wxm37/</a></p>