第二个Datepicker不显示下拉选项

时间:2017-03-04 05:55:42

标签: javascript jquery wordpress datepicker woocommerce

我的结帐页面中有2个datepicker:1表示出生日期,另一个表示航班日期。

enter image description here

第一个是好的,但对于第二个,月和年的下拉选项已经消失/禁用。

enter image description here

以下是出生日期的代码:

$fields['billing']['billing_datebirth'] = array(
        'label'     => __('Date of Birth', 'woocommerce'),
        'id'        => 'billing_datebirth',
        'placeholder'   => _x('MM/DD/YYYY', 'placeholder', 'woocommerce'),
        'autocomplete' => 'off',
        'required'  => false,
        'class'     => array('form-row-first'),
        'clear'     => true,
        'options'     =>   array('' => __('Select BirthDay', 'woocommerce' ))
);

飞行日期:

$fields['order']['shipping_flight_date'] = array(
                                        'label'     => __('Flight Date', 'woocommerce'),
                                        'id'        => 'shipping_flight_date',
                                        'placeholder'   => _x('MM/DD/YYYY', 'placeholder', 'woocommerce'),
                                        'autocomplete' => 'off',
                                        'required'  => false,
                                        'class'     => array('form-row-last'),
                                        'clear'     => true,
                                        'options'     =>   array('' => __('Select Flight Date', 'woocommerce' ))
                                );

当我检查字段时,没有jQuery错误,但这里是HTML代码:

出生日期:

<p class="form-row form-row form-row-first woocommerce-validated" id="billing_datebirth_field">
  <label for="billing_datebirth" class="">Date of Birth<abbr class="required" title="required"> * </abbr></label>
  <input type="text" class="input-text  hasDatepicker" name="billing_datebirth" id="billing_datebirth" placeholder="MM/DD/YYYY" autocomplete="off" value="">
</p>

飞行日期:

<p class="form-row form-row form-row-last woocommerce-validated" id="shipping_flight_date_field">
  <label for="shipping_flight_date" class="">Flight Date<abbr class="required" title="required"> * </abbr></label>
  <input type="text" class="input-text  hasDatepicker" name="shipping_flight_date" id="shipping_flight_date" placeholder="MM/DD/YYYY" autocomplete="off" value="">
</p>

我错过了什么?非常感谢您的帮助。

谢谢!

-Eli

更新:

这是JS:

jQuery('#billing_datebirth').datepicker({ 
    dateFormat: 'mm/dd/yy', 
    changeMonth: true,
    changeYear: true,
    yearRange: "-100:+0",
    defaultViewDate: { year: new Date().getFullYear()-20, month: 0, day:1 }

});
jQuery('#shipping_flight_date').datepicker({
    dateFormat: 'mm/dd/yy',
    changeMonth: true,
    changeYear: true,
    yearRange: "-100:+0",
    defaultViewDate: { year: new Date().getFullYear()-20, month: 0, day:1 }
});

0 个答案:

没有答案