Reputation: 1045
I need to get a series of dates from a mysql database using php, once I query the database and have all my dates as a result of the query, is it then possible to show those dates in for example red on the jquery UI calendar?
Upvotes: 1
Views: 1925
Reputation: 108
Here is some code that should help you. Here's a link to a working version: http://jsfiddle.net/tiborkiray/EXGW4/
CSS:
td.colorRed a {
color: #FF0000;
}
JavaScript:
$('#datepicker').datepicker({
beforeShowDay: function(date) {
// apply your logic in here
if (date == yourDate) {
return [true, 'colorRed', 'ToolTip'];
}
return [true, '', 'ToolTip'];
}
});
The function beforeShowDay takes a date as a parameter and must return an array with [0] equal to true/false indicating whether or not this date is selectable, [1] equal to a CSS class name(s) or "" for the default presentation, and [2] an optional popup tooltip for this date. It is called for each day in the datepicker before it is displayed.
You should make the dates from server side (MySql) available on the client side. Once you have those dates add them to the beforeShowDay logic. In javascript new Date(unix_timestamp*1000); will convert your server side timestamp into one that javascript can consume (1000 is to go from seconds to miliseconds)
Upvotes: 3