我正在尝试禁用并突出显示日历上的禁用日期,但似乎没有任何工作使用jquery和php mysql从数据库中检索禁用的日期。
代码:
<input type="text" id="datepicker">
<script>
$(document).ready(function () {
var arrDisabledDates = {};
arrDisabledDates[new Date('02/22/2018')] = new Date('02/22/2018');
arrDisabledDates[new Date('02/04/2018')] = new Date('02/04/2018');
arrDisabledDates[new Date('02/16/2018')] = new Date('02/16/2018');
arrDisabledDates[new Date('02/28/2018')] = new Date('02/28/2018');
$('#datepicker').datepicker( {
beforeShowDay: function (dt) {
var bDisable = arrDisabledDates[dt];
if (bDisable) return [false, '', ''];
else return [true, '', ''];
}
})
$('#datepicker').on('changeDate', function() {
$('#my_hidden_input').val(
$('#datepicker').datepicker('getFormattedDate')
);
});
});
function highlightDays(arrDiabledDates) {
for (var i = 0; i < dates.length; i++) {
if (new Date(dates[i]).toString() == date.toString()) {
return [true, 'highlight'];
}
}
return [true, ''];
}
</script>