title: How to disable a button if statement
body: <p>How can I disable a button by clicking a certain button? </p>
  
  <p>It looks like this, if I click the Accept button (Accept button only is disabled) other button is enabled. <code>order_status = Accepted</code> then <code>submitAccept</code> button will be disabled. </p>
  
  <p>But what is happening right now is it didn't get the value of order_status (Accepted) even if I change it in dispatched the submitAccept button is still disabled.</p>
  
  <p>UPDATE: It disable button accept BUT it disable ALL accept button even the order_status is dispatched or pending
  Heres my code</p>
  
  <pre><code>&lt;?php 
  
  
   &lt;div class="form-group"&gt;
   &lt;label for="order_status" class="col-sm-2 control-label"&gt;Order Status&lt;/label&gt; 
   &lt;div class="col-lg-3"&gt;
   &lt;input type="text" input style="width:500px" class="form-control" name="order_status" id="order_status" placeholder="" value="" required="required" readonly&gt;
   &lt;/div&gt; 
   &lt;/div&gt;
  
    &lt;?php 
    if(isset($_POST['ORDER_ID'])){  
  $order_id = trim(addslashes($_POST['ORDER_ID']));
  $sql = "SELECT food_name, special_request, quantity, amount 
  FROM cart_tbl
  WHERE order_id=$order_id";
  $result = mysqli_query(connection2(), $sql);}
  ?&gt;
  &lt;table class="table table-hover table-bordered"&gt;
   &lt;thead&gt;
   &lt;tr&gt; 
   &lt;th&gt;Food&lt;/th&gt;
   &lt;th&gt;Special Request&lt;/th&gt;
   &lt;th&gt;Quantity&lt;/th&gt;
   &lt;th&gt;Amount&lt;/th&gt; 
   &lt;/tr&gt;
   &lt;/thead&gt; 
   &lt;?php
  if(mysqli_num_rows($result)&gt;0)
  {
      while($row = mysqli_fetch_array($result))
      {
  ?&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;?php echo $row["food_name"];?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row["special_request"];?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row["quantity"];?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row["amount"];?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;?php
      }
  }
  ?&gt;
  
  &lt;/table&gt;
   &lt;/div&gt;
   &lt;div class="modal-footer"&gt;
  &lt;button type="submit" input style="background-color:##FF0000;color:white;float:left" name="showFood" id="showFood" class="btn btn-primary " onclick="if(!confirm('Are you sure you want to see food order?')){return false;}" &gt; Show Food&lt;/button&gt;
  &lt;button type="submit" input style="background-color:#4CAF50;color:white" name="submitDelivered" id="submitDelivered" class="btn btn-primary " onclick="if(!confirm('Are you sure you want to deliver order?')){return false;}" &gt; Delivered &lt;/button&gt;
  // HERE IT IS\\ &lt;button type="submit" input style="background-color:#0000FF;color:white" name="submitAccept" id="submitAccept" class="btn btn-primary" onclick="if(!confirm('Are you sure you want to accept order?')){return false;}" &lt;?php if($_POST['$order_status']="Accepted"): ?&gt; disabled &lt;?php endif ?&gt; &gt; Accept &lt;/button&gt;
   &lt;button type="button" style="background-color:#FFFF00;color:black" class="btn btn-success" data-toggle="modal" data-target="#myDropdown"&gt; Send &lt;/button&gt; 
   &lt;button type="submit" input style="background-color:#f44336;color:white" name="submitCancel" class="btn btn-danger" onclick="if(!confirm('Are you sure you want to cancel order?')){return false;}"&gt;Cancel&lt;/button&gt; 
    &lt;?php
  if(isset($_POST['submitDelivered'])){  
    $order_id = trim(addslashes($_POST['ORDER_ID']));
    $driver_number= trim(addslashes($_POST['drivers_number']));
    $query = "UPDATE order_tbl SET `order_status`='Delivered' WHERE `order_id` = $order_id";
    if (mysqli_query(connection2(), $query)) { 
           mysqli_query(connection2(), "COMMIT");
           $_SESSION['message'] = "Order Delivered"; } 
           else { 
           $_SESSION['message'] = mysqli_error(connection2());
           mysqli_query(connection2(), "ROLLBACK");
           }
  
    if($_POST['drivers_number']!=0){      
    $query2 = "UPDATE driver_tbl SET `order_id`='' WHERE `driver_number` = $driver_number";
    if (mysqli_query(connection2(), $query2)) { 
           mysqli_query(connection2(), "COMMIT");
           }
      }
    }
  
    if(isset($_POST['submitAccept'])){  
    $order_id = trim(addslashes($_POST['ORDER_ID']));
    $driver_number= trim(addslashes($_POST['drivers_number']));
    $query = "UPDATE order_tbl SET `order_status`='Accepted' WHERE `order_id` = $order_id";
    if (mysqli_query(connection2(), $query)) { 
           mysqli_query(connection2(), "COMMIT");
           $_SESSION['message'] = "Order Accepted"; } 
           else { 
           $_SESSION['message'] = mysqli_error(connection2());
           mysqli_query(connection2(), "ROLLBACK");
           }
  
    if($_POST['drivers_number']!=0){      
    $query2 = "UPDATE driver_tbl SET `order_id`='' WHERE `driver_number` = $driver_number";
    if (mysqli_query(connection2(), $query2)) { 
           mysqli_query(connection2(), "COMMIT");
           }
      }
    }
  
  
    if(isset($_POST['submitCancel'])){  
    $order_id = trim(addslashes($_POST['ORDER_ID']));
    $driver_number= trim(addslashes($_POST['drivers_number']));
    $query = "UPDATE order_tbl SET `order_status`='Cancelled' WHERE `order_id` = $order_id";
    if (mysqli_query(connection2(), $query)) { 
           mysqli_query(connection2(), "COMMIT");
           $_SESSION['message'] = "Order Cancelled"; } 
           else { 
           $_SESSION['message'] = mysqli_error(connection2());
           mysqli_query(connection2(), "ROLLBACK");
           }
  
    if($_POST['drivers_number']!=0){      
    $query2 = "UPDATE driver_tbl SET `order_id`='' WHERE `driver_number` = $driver_number";
    if (mysqli_query(connection2(), $query2)) { 
           mysqli_query(connection2(), "COMMIT");
           }
  
      }
    }
  
    ?&gt;
  
   &lt;/div&gt;
   &lt;/form&gt;
   &lt;/div&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>I also tried this code but nothings happen.</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
    $(function () {
        ($order_status).keyup(function (){
            if ($order_status == 'Accepted') {
                ('.submitAccept').prop('disabled',true);
            }else{
                ('.submitAccept').prop('disabled', false);
            }
    })
    };
    );
  
    &lt;/script&gt;
  </code></pre>