This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_details.html
62 lines (58 loc) · 1.72 KB
/
train_details.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Train Details</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
th {
background-color: #f4f4f4;
}
</style>
</head>
<body>
<h1>Train Details</h1>
<table id="trainTable">
<thead>
<tr>
<th>Train Name</th>
<th>Departure Time</th>
<th>Departure Station</th>
<th>Arrival Station</th>
<th>Arrival Time</th>
</tr>
</thead>
<tbody>
<!-- JavaScript will populate this -->
</tbody>
</table>
<script>
fetch('data/trains.json')
.then(response => response.json())
.then(data => {
const trainTableBody = document.querySelector("#trainTable tbody");
data.forEach(train => {
const row = document.createElement("tr");
row.innerHTML = `
<td>${train.train_name}</td>
<td>${train.departure_time}</td>
<td>${train.departure_station}</td>
<td>${train.arrival_station}</td>
<td>${train.arrival_time}</td>
`;
trainTableBody.appendChild(row);
});
})
.catch(error => console.error('Error fetching train data:', error));
</script>
</body>
</html>