I have implemented the functionality you requested using a jQuery datepicker.
First, add all the dates selected in the back office to be disabled into an array
// format yyyy-mm-dd
var disabledDates = [
"2012-10-01",
"2012-10-02",
"2012-10-30",
"2012-09-12"
];
Second, specify the datepicker with two functions
$("#datepicker").datepicker({
// only enable date if dateEnabled returns [true]
beforeShowDay: dateEnabled,
// once a date has been selected call dateSelected
onSelect: dateSelected
});
Here is the definition of the required functions
function dateEnabled( d ) {
// if date found in array disable date
if( disabledDates.indexOf( getDate( d ) ) > -1 ) {
return [false];
} else {
return [true] ;
}
}
Convert date to string for comparison with dates in array
function getDate( d ) {
var day,
month,
year;
day = d.getDate( );
month = d.getMonth( ) + 1; // add 1 as getMonth returns 0 - 11
year = d.getFullYear( );
if( month < 10 ) month = "0" + month;
if( day < 10 ) day = "0" + day;
return year + "-" + month + "-" + day;
}
Once a date has been selected process it
function dateSelected( d ) {
// do stuff with string representation of date
}
Here is a fiddle http://jsfiddle.net/KYzaR/7/
Just thought it would be worth mentioning that Array.indexOf is a recent addition to ECMA-262 standard and so in the case of IE7 and IE8 it is not supported. The following MDN page provides code that implements Array.indexOf for these browsers https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf