Datepicker dynamic min / max dates

后端 未结 2 754
一向
一向 2021-01-07 06:44

I\'m using the jQuery datepicker plugin on a site I am building. I need users to be able to pick two dates from within a specified range of dates. This is straightforward en

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-07 07:30

    OK, I finally figured this out. I initially define and use the datepicker as normal. When I need to dynamically update it, I use:

    $.getScript('url.php', function() {updateDate(); });
    

    In my case, I use this on change of a select box.

    The php file that is called queries a mysql database outputs the following (using echo):

    function updateDate() {
            $( "#dateStartMainChartSelect" ).datepicker('change',{ 
                minDate: new Date(2011,01,01),
                maxDate: new Date(2011,02,01)
            });
        }
    

    You can add any of the datepicker options here that you want to change. Thanks to JasCav, I ended up looking in the right places for the solution.

提交回复
热议问题