I would like to show number of months shown based on the number of selectable days.
So an example would be that if I have 15 days to select from and the date starts from today (23/04/2013) I would like only April and May to be shown as number of months shown to select from.
Similarly, if the number of selectable days 60 I would like to show April, May and June as the the number of months shown.
So in essence how do I make number of months shown is conditional to the number of selectable days?
Many thanks in advance.
my plugin
$.fn.showCalendar = function(options){
var defaults ={
selector : "#date-selector",
calendarIcon : "./images/icons/calendar.gif",
numberOfSelectableDays : "+60D",
dateFormat: "dd/mm/yy",
numberOfMonths : 3,
daySelector : "#day",
monthSelector : "#month",
yearSelector : "#year"
}
var $this = $(this);
var params = $.extend({},defaults, options);
var getDateFromDropDowns = function(){
var dateOnDropDowns = new Date($(params.daySelector).val(),$(params.monthSelector).val(),$(params.yearSelector).val());
return dateOnDropDowns;
}
return $this.each(function(){
$this.datepicker({
showOn: "button",
buttonImage: params.calendarIcon,
minDate: 0,
maxDate: params.numberOfSelectableDays,
dateFormat: params.dateFormat,
buttonImageOnly: true,
numberOfMonths: params.numberOfMonths,
setDate : getDateFromDropDowns,
onClose: function(dateText, inst) {
$(params.yearSelector).val(dateText.split('/')[2]);
$(params.daySelector).val(dateText.split('/')[0]);
$(params.monthSelector).val(dateText.split('/')[1]);
}
});
});
},