How can I add JavaScript code to datepicker
I have placed a datepicker on my page and I'd like to add the following JavaScript properties to it. However, when I create an OnClick Event and execute the JavaScript, it does not work. Please refer to screenshot....it creates another calendar (the second one) and adds the color dates to that one. Why does it create the first calendar? How can I fix this.
pre
var redDates = ['8/27/2014', '8/28/2014', '8/29/2014', '8/31/2014', '8/30/2014'];
var greenDates = ['8/15/2014', '8/16/2014', '8/17/2014'];
$('div[dsid="mydatepicker"]').datepicker({
//numberOfMonths: 2,
selectMultiple: true,
beforeShowDay: function(date) {
var theday = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
return [true, ($.inArray(theday, redDates) = 0 ? "specialDate2" : ($.inArray(theday, greenDates) = 0 ? "specialDate1" : ""))];
},
Code: Select all
onSelect: function(date) {
date = new Date(date);
var theday = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
if ($.inArray(theday, greenDates) = 0) {
greenDate = theday;
}
$('div[dsid="mydatepicker"]').datepicker("refresh");
}