-
Notifications
You must be signed in to change notification settings - Fork 0
/
seat.html
64 lines (60 loc) · 1.83 KB
/
seat.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Seat Booking</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
.seat {
width: 30px;
height: 30px;
margin: 5px;
background-color: #28a745;
color: white;
cursor: pointer;
}
.seat.selected {
background-color: #ffc107;
}
.seat.booked {
background-color: #dc3545;
cursor: not-allowed;
}
.legend {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<h2 class="text-center my-4">Select Your Seats</h2>
<div id="seat-map" class="d-flex flex-wrap justify-content-center"></div>
<div class="legend d-flex justify-content-center">
<div class="seat mx-2"></div> Available
<div class="seat mx-2 selected"></div> Selected
<div class="seat mx-2 booked"></div> Booked
</div>
<h4 class="text-center mt-4">Total Price: <span id="total-price">0</span> USD</h4>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
const seatPrice = 10;
let totalSeats = [];
$(document).ready(function() {
// Fetch seats from the server
$.get("fetch_seats.php", function(data) {
$('#seat-map').html(data);
});
$(document).on('click', '.seat.available', function() {
$(this).toggleClass('selected');
updateTotal();
});
});
function updateTotal() {
let selectedSeats = $('.seat.selected').length;
$('#total-price').text(selectedSeats * seatPrice);
}
</script>
</body>
</html>