I'm trying to write a web page which tells user to input a date of booking, this input field has jQuery calender. I've also successfully disable specific dates so no 2 users book a same date.
My question is how can I read a file from server, get Dates, process and disable them in jQuery calender? Or is there a way to send data from PHP to JavaScript? JSFiddle. Here is my code:
var eventDates = ["28/1/2018", "27/1/2018", "2/2/2018"];
$(function() {
$("#iDate").datepicker({
beforeShowDay : function(date) {
var disDate = date.getDate();
var disMonth = date.getMonth();
var disYear = date.getFullYear();
var formattedDate = disDate + "/" + (disMonth + 1) + "/" + disYear;
if ($.inArray(formattedDate, eventDates) != -1) {
return[false]
} else {
return[true]
}
}
});
});
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
</head>
<body>
Date: <input id="iDate">
</body>
</html>