在引导日历中签入/退房日期加载问题

Check-in / Check-out date loading issue in Bootstrap Calendar

本文关键字:日期 加载 问题 日历      更新时间:2023-09-26

从下面的代码,如果我点击入住日期为2014年6月17日,日历将直接弹出退房日历为2014年5月18日,但我需要日历弹出显示2014年6月17日。有没有人可以帮助我,下面是我的代码。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/bootstrap-datepicker.js" type="text/javascript"></script>
<script>
    $(document).ready(function(e) {
        var nowTemp = new Date();
        var now = (nowTemp.getMonth()+1)+'-'+ nowTemp.getDate()+'-'+ nowTemp.getFullYear();

        $('#sandbox-container .input-append.date').datepicker({
            orientation: "auto",
            autoclose: true,
            todayHighlight: true,
            startDate:now
            }).on('changeDate', function(ev) {
                $('#sandbox-container1 span').trigger('click');
                $('.input-append.date.span12').css({display:'block'}).show();
            }); 
        var nowTemp1 = new Date();
        var now1 = (nowTemp1.getMonth()+1)+'-'+ (nowTemp1.getDate()+1)+'-'+ nowTemp1.getFullYear();
        $('#sandbox-container1 .input-append.date').datepicker({
            orientation: "auto",
            autoclose: true,
            startDate:now1
        });
    });
</script>

<div id="sandbox-container" class="book_arriv_input f-left">
    <div data-date-format="mm-dd-yyyy" data-date="12-12-2013" id="dp1" class="input-append date" >
        <input type="text" id="check_in" name="checkin_date_avail" class="span6"/>
        <span> 
            <div class="add-on calender" style="margin-left: -5px;">
                <i class="icon-th"></i>
            </div>
        </span>
    </div>
</div>

<div id="sandbox-container1" class="book_arriv_input f-left">
    <div data-date-format="mm-dd-yyyy" data-date="12-13-2013" id="dp2" class="input-append date">
        <input type="text" id="check_out" name="checkout_date_avail" class="span6"><span class="add-on calender" style="margin-left: -5px;"><i class="icon-th"></i></span>
    </div>
</div>

第二个日期在17号被禁用,因为now1从一天后开始。你可以用now代替now1。编辑:您可以根据签入选择器在签出选择器上设置日期,如下所示:

picker1 = $('#sandbox-container1 .input-append.date').datepicker()
picker1.data('datepicker').setDate(pickedDate);

小提琴:http://jsfiddle.net/tp2MP/