如果从另一个php页面调用Javascript,如何将其实现到模式中

如果从另一个php页面调用Javascript,如何将其实现到模式中,javascript,php,twitter-bootstrap,Javascript,Php,Twitter Bootstrap,在index.php中,我有一个带有orders的表,当我单击order进行修改时,会显示一个模式,但来自页面call edit.php。现在,正如您在屏幕截图中看到的: 我有很多麻烦,我不能实现任何Javascript,比如datepicker、Google地址自动完成 index.php中的href: <a href="edit.php" data-toggle='modal' data-target = "#action2" class ="btn btn-primary">

在index.php中,我有一个带有orders的表,当我单击order进行修改时,会显示一个模式,但来自页面call edit.php。现在,正如您在屏幕截图中看到的:

我有很多麻烦,我不能实现任何Javascript,比如datepicker、Google地址自动完成

index.php中的href:

 <a href="edit.php" data-toggle='modal' data-target = "#action2" class ="btn btn-primary"> <span class = "glyphicon glyphicon-edit"></span> Edit </a></a>

Edit.php

<?php
include_once("config.php");
$q_customer = $conn->query
    ("SELECT * from orders inner JOIN mydate on orders.order_no=mydate.order_no and orders.date=mydate.order_date" ) or die(mysqli_error());
$f_customer = $q_customer->fetch_array();
?>
<form method = "POST" action = "save_customer_query.php" enctype = "multipart/form-data" class = "modal-body" id = "action2">
    <center>
        <label class = "text-info">Update Order information</label>
    </center>
    <div class  = "modal-body">
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Order Date</label>
            <input type = "text" name = "orderdatepicker"  id="orderdatepicker" value = "<?php echo $f_customer['date']?>" class="form-control"/>
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Order Number</label>
            <input type = "text" name = "order_no"  id="order_no" tabindex="1" value = "<?php echo $f_customer['order_no']?>" class="form-control" autofocus />
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Phone Number</label>
            <input type = "text" name = "phone"  id="phone" tabindex="1" class="form-control"  />
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">First Name</label>
            <input type = "text" name = "first_name"  id="first_name" tabindex="2" class = "form-control"  />
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Last Name</label>
            <input type = "text" name = "last_name" id="last_name"tabindex="3" class = "form-control" />
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Email</label>
            <input type = "text" name = "email"  id="email" tabindex="4" class = "form-control" />
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Company</label>
            <input type = "text" name = "company"  id="company" tabindex="5" class = "form-control" />
        </div>
        <div class="form-group col-xs-4 col-md-4">
            <label for="name" class="control-label">Address</label>
            <div id="locationField">
                <input id="autocomplete" name = "address"  onFocus="geolocate()" type="text" class = "form-control" value = "<?php echo $f_customer['address']?>"/>
            </input>
        </div>
    </div>
    <div class="form-group col-xs-4 col-md-4">
        <label for="timepicker_6" class="control-label">Kitchen Time </label>
        <input type="text"  id="timepicker_6" name = "k_time" value = "<?php echo $f_customer['k_time']?>" class = "form-control"/>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#timepicker_6').timepicker({
                    showPeriod: true,
                    showLeadingZero: true
                });
            });
        </script>
    </div>
    <div class="form-group col-xs-4 col-md-4">
        <label for="timepicker_7" class="control-label">Delivery Time </label>
        <input type="text" id="timepicker_7" name = "d_time" value = "<?php echo $f_customer['d_time']?>" class = "form-control"/>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#timepicker_7').timepicker({
                    showPeriod: true,
                    showLeadingZero: true 
                });
            });
        </script>
    </div>
    <div class="form-group col-xs-4 col-md-4">
        <label for="name" class="control-label">Driver</label>
        <input type = "text" name = "driver_no"  id="driver_no"  tabindex="5" class = "form-control" />
    </div>
    <div class="form-group col-xs-4 col-md-4">
        <label for="name" >No of People</label>
        <input type = "text" name = "no_ofppl"  id="no_ofppl" tabindex="5" class = "form-control" />
    </div>
</div>
<div class = "form-group col-xs-4 col-md-4">
    <button  class = "btn btn-default" data-dismiss = "modal" ><span class = "glyphicon glyphicon-remove"></span> Cancel</button>
</div>
<div class = "modal-footer">
    <button  class = "btn btn-primary" name = "save" tabindex="7" id="save" ><span class = "glyphicon glyphicon-save"></span> Save</button>
</div>
</form> 

更新订单信息
订购日期

您需要做的是代替在
文档上绑定
时间选择器
。ready
方法在
模式显示的
事件中绑定模式弹出窗口中使用的所有时间选择器,如下所示,它对日期选择器、google地址自动完成执行相同的操作以使其工作

$('#action2').on('shown.bs.modal', function () {
    $('#timepicker_6').timepicker({
            showPeriod: true,
            showLeadingZero: true
     }); 

});

尽管它在控制台中抛出了什么错误,它还是应该可以工作的。我之前在index.php$('#mymodal').on('show.bs.modal',function(){window.location=“index.php”中添加了这段代码;但没有执行您的id
#mymodal
是否正确?它似乎应该是
#action2
?是的,将其放入
文档中。准备就绪
以及它的#action2,错误,窗口。位置工作正常,但时间选择器不正确,即使它在我添加新订单时工作,但不在show modal上进行修改它似乎在更新订单上有这样的功能我做错了检查你的控制台上面写了什么?