Pick multiple dates one by one with Jquery/Datepicker

我只是一个虾纸丫 提交于 2020-02-03 09:31:21

问题


I have a form and on that form I would like to have a datepicker. So when someone clicks select dates field the datepicker pops up and shows multiple months. From there I would like for the person to click individual dates, each click the date they selected gets appended to the form field comma seperated. Im looking for a jquery solution, right now Im looking at:

http://jqueryui.com/demos/datepicker/#multiple-calendars

The problem is when I select a date the datepicker closes then the date selected shows up in the form field. I want the datepicker to continue to show while they select multiple dates and the dates they selected stay highlighted, then click done when they are done selecting dates. Can anyone point me to how I can accomplish this or is there a pre-existing jquery code that does that?


回答1:


try out this plugin (demo near bottom of page): http://multidatespickr.sourceforge.net/




回答2:


For anyone landing here trying to get multi date picker to highlight the dates selected- you can use the beforeshowday event like so to add a class.

NB: this will add a class to everything that Hasn't been selected yet, meaning you can style this normally and use the usual classes for your selected styling.

$( '#booking_date' ).multiDatesPicker({ 
        beforeShowDay: function(date) {
             return [true, 'myClass'];
      }
});


来源:https://stackoverflow.com/questions/6539694/pick-multiple-dates-one-by-one-with-jquery-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!