My question may be simple or something similar to other question, But i am just unable to accomplish this task.
I am trying to disable some dates in datepicker dynamically. I am just running a query which gives a list of holidays.
$date[]=$year.'/'.$month.'/'.$day; // array
and i am using implode so that i can have comma separated list
$abc=implode(',',$date);
so $abc contains dates.
Here is my javascript
<script type="text/javascript">
//var Alldays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];
/* var disable= '<?php echo $info; ?>'; // yyyy/MM/dd*/
var disableDates="<?php =$abc; ?>";
//var disableDays = ["Saturday", "Sunday"];
//var disableDates = ["2013/02/26", "2013/02/28"];
alert (disableDates);
function ShowDisableDates(date) {
ymd = date.getFullYear() + "/" + ("0" + (date.getMonth() + 1)).slice(-2) + "/" + ("0" + date.getDate()).slice(-2);
//alert(ymd);
//ymd= ("0" + (date.getMonth() + 1)).slice(-2) + "/" + ("0" + date.getDate()).slice(-2) + "/" + date.getFullYear();
day = new Date(ymd).getDay();
if ($.inArray(ymd, disableDates) < 0 ) {
return [true, "enabled", "Book Now"];
} else {
return [false, "disabled", "Sold Out"];
}
}
$(function() {
$("#datepicker").datepicker({beforeShowDay:ShowDisableDates});
});
</script>
But i am not able to access the dates from $abc to javascript.
If i declare them as static as
var disableDates = ["2013/02/26", "2013/02/28"];
It works fine
Please guide me to solve this, Thanks