Jquery datepicker to show multiple color on date selection -
i have date picker shows active days. within these active days, need show different color on selecting each date instead of date picker's default color. have 3 array of dates determines color show.
array1 = {8/5/2013, 8/14/2013, 8/21/2013} - background blue array2 = {8/15/2013, 8/22/2013} - background red array3 = {8/9/2013, 8/13/2013} - background green
how can extend date picker achieve this?
like this: jsfiddle example
$('#dp').datepicker({ beforeshowday: colorize }); var bluedates = ['8-5-2013', '8-14-2013', '8-21-2013']; var greendates = ['8-15-2013', '8-22-2013']; var reddates = ['8-9-2013', '8-13-2013']; function colorize(date) { mdy = (date.getmonth() + 1) + '-' + date.getdate() + '-' + date.getfullyear(); console.log(mdy); if ($.inarray(mdy, bluedates) > -1) { return [true, "blue"]; } else if ($.inarray(mdy, greendates) > -1) { return [true, "green"]; } else if ($.inarray(mdy, reddates) > -1) { return [true, "red"]; } else { return [true, ""]; } }
Comments
Post a Comment