2
I have a system in Classic ASP, in which I have a scheduling calendar. I need to disable the dates that are in the table of holidays and compensations (id_holiday and date). I don’t know how to select an array of unavailable dates.
To do something similar to the variable line unavailableDates.
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
var unavailableDates = ["2012/03/26","2012/03/27","2012/04/05"]; // yyyy/MM/dd**
var unavailableDays = ["Saturday","Sunday"];
function unavailable(date) {
ymd = date.getFullYear() + "/" + ("0"+(date.getMonth()+1)).slice(-2) + "/" + ("0"+date.getDate()).slice(-2);
day = new Date(ymd).getDay();
if ($.inArray(ymd, unavailableDates) < 0 && $.inArray(days[day], unavailableDays) < 0) {
return [true, "enabled", "Book Now"];
} else {
return [false,"disabled","Booked Out"];
}
}
$('#iDate').datepicker({ beforeShowDay: unavailable });
Are you using the datepicker jQuery UI?
– Leonel Sanches da Silva
I don’t know another datepicker with the option "beforeShowDay"
– Tobias Mesquita
mmooser, posted the answer below to try to help you with the script, but I believe your real doubt is how popular the array
unavailableDates
with the holidays, in this case I will ask you to put the structure of the table of holidays.– Tobias Mesquita
Toby, my question is regarding the popular yes array. Putting the dates manually I can, but as it is not only the holidays, it is complicated I have to change the file every time. The table tb_holidays has the following structure: id_feriado - int (self-numbered) data - datetime
– mmooser
"are not only the holidays, "what else then?
– Pedro Sanção
They are specific dates such as end of year recess. In addition to the holidays.
– mmooser