I am making a form for scheduling. It has date and time. If someone picks Saturday, available hours are from 8:30 to 12:00. Monday- Friday: 8:30 to 15:30.
I have this:
var datum = "";
jQuery("#meeting_date").change(function(){
$("#meeting_time").html("");
datum = $(this).val().split("-");
day_of_the_week =new Date(datum[2], datum[1]-1, datum[0]).getDay();
if(day_of_the_week==6) {
$("#meeting_time").timepicker({
timeFormat: ("H:mm"),
minTime: "8:30",
maxTime: "12:00"
});
}
else {
$("#meeting_time").timepicker({
timeFormat: ("H:mm"),
minTime: "8:30",
maxTime: "15:00"
});
}
});
It works fine on the first date change. On the ones that follow, the timepicker doesn't change. How can I reset it?
Ok, so I've found the solution, thanks to @mu is too short and his answer to this question Jquery TimePicker : How to dynamically change parameters.
I needed to use OPTIONS to readjust the MAX DATE:
var datum = "";
jQuery("#meeting_date").change(function(){
$("#meeting_time").html("");
datum = $(this).val().split("-");
day_of_the_week =new Date(datum[2], datum[1]-1, datum[0]).getDay();
if(day_of_the_week==6) {
$("#termin_sastanka").timepicker('option', 'maxTime', "12:00");
}
else {
$("#termin_sastanka").timepicker('option', 'maxTime', "15:00");
}
});