在PHP中删除菜单不起作用

时间:2018-02-25 03:19:45

标签: php jquery wordpress

我试图通过jQuery使用txt文件而不是数据库来提取选项。

如果文件保存在html文件下,一切正常,但是当我移动到PHP文件时,下拉菜单不会产生任何影响。

我首先调用了php中的代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

然后

<script>
$(function() {
    $("#pickup_location").change(function() {
    $("#drop_location").load("textdata/" + $(this).val() + ".txt");
    });
});
</script>

这是菜单

<div class="form-group col-sm-6">
    <label> <?php echo simontaxi_get_pickuppoint_title(); ?><?php echo simontaxi_required_field(); ?></label>
    <div class="inner-addon right-addon">
        <?php
        if ( 'predefined_place' === $predefined_place && 'dropdown' === $vehicle_places_display ) {
        $pickup_locations = simontaxi_get_locations( 'pickup_location' );
        $pickup_location = simontaxi_get_value( $booking_step1, 'pickup_location_new' );
        ?>
        <select name="pickup_location" id="pickup_location" class="selectpicker show-tick show-menu-arrow" data-width="100%" data-size="5">
            <option value=""><?php esc_html_e( 'Please select ' .simontaxi_get_pickuppoint_title() ) ?></option>
            <option value="416" >1</option>                                                                     
            <option value="532" >2</option>
            <option value="509" >3</option>
            <option value="505" >4</option>
        </select>
        <?php } else { 
        $plocation = simontaxi_get_value( $booking_step1, 'pickup_location' );
        if ( empty( $plocation ) ) {
            $plocation = simontaxi_get_value( $booking_step1, 'pickup_location_new' );
        }
        ?>
        <i class="st-icon icon-location-pin"></i>
        <input type="text" class="form-control required <?php echo $predefined_place ?>" placeholder="<?php echo simontaxi_get_pickuppoint_title(); ?>" name="pickup_location" id="pickup_location" <?php echo (in_array( $vehicle_places, array( 'googleall', 'googleregions', 'googlecities' ) ) ) ? 'onClick="initialize(this.id);" onFocus="initialize(this.id);"' : ''; ?> value="<?php if ( $modify ){ echo $plocation; }?>" autocomplete="off" tabIndex="0"/>
        <?php } ?>
        <input type="hidden" id="pickup_location_country" name="pickup_location_country" value="<?php if ( $modify ){ echo simontaxi_get_value( $booking_step1, 'pickup_location_country' ); }?>">
        <input type="hidden" id="pickup_location_lat" name="pickup_location_lat" value="<?php if ( $modify ){ echo simontaxi_get_value( $booking_step1, 'pickup_location_lat' ); }?>">
        <input type="hidden" id="pickup_location_lng" name="pickup_location_lng" value="<?php if ( $modify ){ echo simontaxi_get_value( $booking_step1, 'pickup_location_lng' ); }?>">
    </div>
</div>
<div class="form-group col-sm-6">
    <label> <?php echo simontaxi_get_dropoffpoint_title(); ?><?php echo simontaxi_required_field(); ?></label>
    <div class="inner-addon right-addon">
        <?php if ( '' !== $predefined_place_dropoff && 'dropdown' === $vehicle_places_dropoff_display ) {
        $drop_locations = simontaxi_get_locations( 'drop_location' );
        $drop_location = simontaxi_get_value( $booking_step1, 'drop_location_new' );
        ?>
        <select name="drop_location" id="drop_location" class="selectpicker show-tick show-menu-arrow" data-width="100%" data-size="5" >
        <option value=""><?php esc_html_e( 'Please select ' . simontaxi_get_dropoffpoint_title() ) ?></option>
        </select>
        <?php
        } else {
            $dlocation = simontaxi_get_value( $booking_step1, 'drop_location' );
            if ( empty( $dlocation ) ) {
                $dlocation = simontaxi_get_value( $booking_step1, 'drop_location_new' );
            }
        ?>
        <i class="st-icon icon-location-pin"></i>
        <input type="text" class="form-control <?php echo $predefined_place_dropoff?>" placeholder="<?php echo simontaxi_get_dropoffpoint_title(); ?>" <?php echo (in_array( $vehicle_places_dropoff, array( 'googleall', 'googleregions', 'googlecities' ) ) ? 'onClick="initialize(this.id);" onFocus="initialize(this.id);"' : '' ) ?> value="<?php if ( $modify ){ echo $dlocation; }?>" name="drop_location" id="drop_location" autocomplete="off" tabIndex="1"/>
        <?php } ?>
        <input type="hidden" id="drop_location_country" name="drop_location_country" value="<?php if ( $modify ){ echo simontaxi_get_value( $booking_step1, 'drop_location_country' ); }?>">
        <input type="hidden" id="drop_location_lat" name="drop_location_lat" value="<?php if ( $modify ){ echo simontaxi_get_value( $booking_step1, 'drop_location_lat' ); }?>">
        <input type="hidden" id="drop_location_lng" name="drop_location_lng" value="<?php if ( $modify ){ echo simontaxi_get_value( $booking_step1, 'drop_location_lng' ); }?>">
    </div>
</div>

寻找你的帮助,这个问题让我陷入困境,因为它在html页面中运行良好

0 个答案:

没有答案