I am trying to develop an appointment system. I tried to enable available dates in a date picker, but the problem is that it enables only one day.
$('#doctor').on('change', function() {
var drId = this.value;
$('#timetable').html('');
$.ajax({
url: '{{ route('
getTimes ') }}?dr_id=' + drId,
type: 'get',
success: function(res) {
console.log(res);
$('#timetable').html('<option value="">Select Day Time</option>');
$.each(res, function(key, value) {
const weekday = [, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satarday"];
const d = new Date();
//Disabled by Day Name
$(document).ready(function() {
$('#datepicker').datepicker({
beforeShowDay: filterDays
});
});
// getDay() method returns the day of the week (from 0 to 6) where
// Sunday is 0, Monday is 1, and so on.
function filterDays(date) {
var day = date.getDay();
//return true only if day is Wed or Fri or Sun
return [day[value.day_name]]
}
$('#timetable').append('<option value="' + value.id + '">' + value.start_time + value.end_time + '</option>');
});
}
});
});
Here return [day[value.day_name]] shows only Sunday, but there is another 3 days had stored in the database. It's passes only a single value.
Please help me to do this.