-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrop2.php
69 lines (65 loc) · 2.25 KB
/
drop2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<script>
$(document).ready(function() {
// Function to fetch room_id based on selected room_no
function fetchRoomId(roomNo) {
$.ajax({
url: 'fetchRoomId.php', // Change to your backend file name
method: 'POST',
data: {
roomNo: roomNo
},
success: function(response) {
var roomId = response;
$("#room_id").val(roomId);
},
error: function(xhr, status, error) {
console.error('Error fetching room_id:', error);
}
});
}
// Function to fetch available rooms based on selected date range and room_id
function fetchAvailableRooms(checkInDate, checkOutDate, roomId) {
$.ajax({
url: 'checkAvailability.php', // Change to your backend file name
method: 'POST',
data: {
checkInDate: checkInDate,
checkOutDate: checkOutDate,
roomId: roomId
},
success: function(response) {
console.log('Available dates:', response);
$("#checkInDate, #checkOutDate").datepicker("refresh");
},
error: function(xhr, status, error) {
console.error('Error fetching available dates:', error);
}
});
}
// Initialize Datepicker for check-in date
$("#checkInDate").datepicker({
minDate: 0,
dateFormat: 'yy-mm-dd',
onSelect: function(selectedDate) {
var checkOutDate = $("#checkOutDate").val();
var roomId = $("#room_id").val();
fetchAvailableRooms(selectedDate, checkOutDate, roomId);
}
});
// Initialize Datepicker for check-out date
$("#checkOutDate").datepicker({
minDate: 0,
dateFormat: 'yy-mm-dd',
onSelect: function(selectedDate) {
var checkInDate = $("#checkInDate").val();
var roomId = $("#room_id").val();
fetchAvailableRooms(checkInDate, selectedDate, roomId);
}
});
// Event listener for room selection
$("#room_no").change(function() {
var selectedRoomNo = $(this).val();
fetchRoomId(selectedRoomNo);
});
});
</script>