日期选择器未正确显示。我认为有些事情会干扰它

时间:2018-04-04 07:27:08

标签: php

我的日期选择器出现问题或者某些内容干扰了代码。我认为有些东西在干扰它,因为我使用了我的其他样本中的这个datepicker代码。每当我点击文本框时,都会显示日期选择器。

样本图片。

Sample Picture

这是我的代码。

<?php include('session.php'); ?>
<?php include('header.php'); ?>
<body>
<?php include('navbar.php'); ?>
<div class="container">
<div style="height:50px;"></div>
    <div class="row">
        <div class="col-lg-12">     <center>
            <h1 class="page-header">Product Sales Report</h1></center>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <center>
 <form action="total_sales.php" method="post">
  From: <input type="text" class="datepicker" placeholder="E.G.(2018-01-14)" name="dayfrom" required pattern="[0-9]{4}+[0-9]+[0-9]"> To: <input type="text" class="datepicker" placeholder="E.G.(2018-02-11)" name="dayto" required pattern="[0-9]{4}+[0-9]+[0-9]">
  <input type="submit" value="Show Sales" name="salesbtn" ></form></center>

            <table width="100%" class="table table-striped table-bordered table-hover" id="prodTable">
                <thead>
                    <tr>
                        <th class="hidden"></th>
                        <th>Purchase Date</th>
                        <th>Customer</th>
                        <th>Product Name</th>
                        <th>Quantity</th>
                    </tr>
                </thead>
                <tbody>
                <?php
                    $sq=mysqli_query($conn,"select * from sales_detail left join product on product.productid=sales_detail.productid left join sales on sales.salesid=sales_detail.salesid left join customer on sales.userid=customer.userid where product.supplierid='".$_SESSION['id']."' order by sales.sales_date desc");;
                    while($sqrow=mysqli_fetch_array($sq)){

                    ?>
                        <tr>
                            <td class="hidden"></td>
                            <td><?php echo date('M d, Y h:i A',strtotime($sqrow['sales_date'])); ?></td>
                            <td><?php echo $sqrow['customer_name']; ?></td>
                            <td><?php echo $sqrow['product_name']; ?></td>
                            <td><?php echo $sqrow['sales_qty']; ?></td>
                        </tr>
                    <?php
                    }
                ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?php include('script.php'); ?>
<?php include('modal.php'); ?>
<?php include('add_modal.php'); ?>
<script src="custom.js"></script>
</body>
</html>

这是我的剧本。 我的代码是否缺少datepicker脚本?请帮忙

<script src="../vendor/jquery/jquery.min.js"></script>
<script src="../vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="../dist/js/sb-admin-2.js"></script>

<!-- DataTables JavaScript -->
<script src="../vendor/datatables/js/jquery.dataTables.min.js"></script>
<script src="../vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
<script src="../vendor/datatables-responsive/dataTables.responsive.js"></script>

<script>
$(document).ready(function() {
    $('#dataTables-example').DataTable({
        responsive: true
    });
});
</script>

1 个答案:

答案 0 :(得分:1)

在script.js中使用datepicker js文件

Html代码

<input type="text" id="from_date">

的Javascript

$(function(){
    $( "#from_date" ).datepicker();        
});

或者你可以使用这个

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker"></p>


</body>
</html>