1

I have three datepickers - I have one datepicker which shows a six month span across the top, and then two date pickers beneath that applied to input fields. When the input fields are changed, I want the datepicker across the top of the webpage to highlight the start and end dates, and all the dates in between.

I have so far been able to get it to highlight both the start and end date as you can see in the following code, but I'd really appreciate someones help in how I should go about highlighting the days in between.

    var $test = $.datepicker.formatDate('yy-m-d', $('#date-start').datepicker('getDate'));
    var $test2 = $.datepicker.formatDate('yy-m-d', $('#date-end').datepicker('getDate'));

    var dates1 = {};
    dates1[$test] = 'first date';

    var dates2 = {};
    dates2[$test2] = 'second date';

    $( "#calendar" ).datepicker({
            firstDay: 1,
            numberOfMonths: 6,
            dateFormat: 'yy-mm-dd',
            beforeShowDay: function(date) {
            var search = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate());

                    if (dates1[search]) {

                      return [true, 'highlight', dates1[search] || ''];
                    }

                    if (dates2[search]) {

                      return [true, 'highlight', dates2[search] || ''];

                    }

                    return [false, '', ''];

            },
            onSelect: select_arrive,
            minDate: '+' +minimumLeadDays+ 'D',
            onChangeMonthYear: get_availability
    });

Thanks for any help in advance!

Edit: Thanks for your help, I'll take a look at those links and see if I can figure it out - thanks again! :)

4

1 回答 1

0

感谢大家的帮助。我在这里找到了我想做的解决方案:

需要在 jquery datepicker 中突出显示日期范围

这很好而且很简单,我希望它可以帮助其他人:)

于 2013-05-10T12:58:59.150 回答