如何防止退出模态

时间:2017-09-17 05:34:47

标签: javascript php jquery

如果点击按钮即使刷新,如何阻止ordermodal.php关闭?

我想要发生的是当我点击一个按钮时它会刷新模态,但它也不会关闭模态。

是事件处理程序吗?我不确定。

这是我的ordermodal.php代码

<?php

include_once 'ordermodal2.php';

/** *ordermodal.php **/

$id = "";
$order_date = "";
$order_time = "";
$order_id = "";
$order_deliverCharge = "";
$order_status = "";
$order_totalAmount= "";
$coordinates = "";
$driver_number = "";
$address = "";


$food_name="";
$special_request="";
$quantity="";
$amount="";
$orders="";

?>

<!-- MODALS --> <!-- DETAILS -->
<div id="myModal" class="modal fade" role="dialog" style="z-index: 1400;">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <form action="" method="post" class="form-horizontal">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><center>&times;</button>
          <h4 class="modal-title" id="titleModal">Order Information</h4>
        </div>
        <div class="modal-body">

          <div class="form-group">
            <label for="order_id" class="col-sm-2 control-label">Order ID</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="ORDER_ID" id="ORDER_ID" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="id" class="col-sm-2 control-label">User ID</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="user_id" id="user_id" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="order_date" class="col-sm-2 control-label">Order Date</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="order_date" id="order_date" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="order_time" class="col-sm-2 control-label">Order Time</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="order_time" id="order_time" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="order_deliverCharge" class="col-sm-2 control-label">Delivery Charge</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="order_deliveryCharge" id="order_deliveryCharge" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="order_totalAmount" class="col-sm-2 control-label">Total Amount</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="order_totalAmount" id="order_totalAmount" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="address" class="col-sm-2 control-label">Address</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="address" id="address" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="coordinates" class="col-sm-2 control-label">Coordinates</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="coordinates" id="coordinates" placeholder="" value="" required="required" maxlength="11" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="driver_number" class="col-sm-2 control-label">Driver Number</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="drivers_number" id="drivers_number" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <div class="form-group">
            <label for="order_status" class="col-sm-2 control-label">Order Status</label>
            <div class="col-lg-3">
              <input type="text" input style="width:500px" class="form-control" name="order_status" id="order_status" placeholder="" value="" required="required" readonly>
            </div>
          </div>

          <?php
          $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);
          ?>
          <table class="table table-hover table-bordered">
            <thead>
              <tr>
                <th>Food</th>
                <th>Special Request</th>
                <th>Quantity</th>
                <th>Amount</th>
              </tr>
            </thead>
            <?php
            if(mysqli_num_rows($result)>0)
            {
              while($row = mysqli_fetch_array($result))
              {
              ?>
              <tr>
                <td><?php echo $row["food_name"];?></td>
                <td><?php echo $row["special_request"];?></td>
                <td><?php echo $row["quantity"];?></td>
                <td><?php echo $row["amount"];?></td>
              </tr>
              <?php
              }
            }
            ?>

          </table>
        </div>
        <div class="modal-footer"> //This are the buttons
          <button type="submit" input style="background-color:#00000;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;}"> Show Food </button>
          <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;}" > Delivered </button>
          <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;}" > Accept </button>
          <button type="button" style="background-color:#FFFF00;color:black" class="btn btn-success" data-toggle="modal" data-target="#myDropdown" onclick="send('<?= $_POST['order_id'] ?>')"> Send </button>
          <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;}">Cancel</button>
          <?php
          if(isset($_POST['submitDelivered'])){
            $order_id = trim(addslashes($_POST['ORDER_ID']));
            $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(isset($_POST['submitAccept'])){
            $order_id = trim(addslashes($_POST['ORDER_ID']));
            $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(isset($_POST['submitCancel'])){
            $order_id = trim(addslashes($_POST['ORDER_ID']));
            $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");
            }
          }

          ?>

        </div>
      </form>
    </div>
  </div>
</div>
<script>
function send(order_id) {
  document.getElementById("titleModal2").innerHTML = "Choose Driver";
  document.getElementsByName("ORDER_ID_MODAL_2")[0].setAttribute("value", order_id);
  document.getElementsByName("send")[0].setAttribute("name", "send");
}
</script>

0 个答案:

没有答案