Hi All,
I found this code to disable dates in jquery datepicker
$(function() {
$( "#pickdate" ).datepicker({
dateFormat: 'dd MM yy',
beforeShowDay: checkAvailability
});
})
for the datepicker stuff, and then:
var $myBadDates = new Array("10 October 2010","21 October 2010","12 November 2010");
function checkAvailability(mydate){
var $return=true;
var $returnclass ="available";
$checkdate = $.datepicker.formatDate('dd MM yy', mydate);
for(var i = 0; i < $myBadDates.length; i++)
{
if($myBadDates[i] == $checkdate)
{
$return = false;
$returnclass= "unavailable";
}
}
return [$return,$returnclass];
}
Now I'm getting my dates from a mysql table like this
$.getJSON('checkDates.php?dld='+ id,
function(json) {
for( var i in json) {
$myBadDates = new Array(json[i].start);
}
}
);
This code works except only the last entry of the database table is disabled in the datepicker. I guess $myBadDates = new Array(json.start); isn't the right code of creating an array from json?
How do I create an javascript array from json?
Thanks,
Leon