<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Flight Passenger Details</title> <style> /* CSS Styling */ body, html { margin: 0; padding: 0; height: 100%; font-family: Arial, sans-serif; } .background-image { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-image: url('https://v...content-available-to-author-only...r.com/1920x1080'); /* Replace with your flight image */ background-size: cover; background-position: center; z-index: -1; opacity: 0.7; } .container { position: relative; z-index: 1; max-width: 600px; margin: 50px auto; padding: 20px; background: rgba(255, 255, 255, 0.8); border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1 { text-align: center; color: #333; } form { display: flex; flex-direction: column; } label { margin-bottom: 5px; font-weight: bold; } input { margin-bottom: 15px; padding: 10px; border: 1px solid #ccc; border-radius: 5px; } button { padding: 10px; background-color: #007BFF; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #0056b3; } .details-container { margin-top: 20px; padding: 20px; background: rgba(255, 255, 255, 0.9); border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .details-container h2 { margin-top: 0; color: #333; } .details-container p { margin: 5px 0; color: #555; } </style> </head> <body> <!-- HTML Structure --> <div class="background-image"></div> <div class="container"> <h1>Flight Passenger Details</h1> <form id="detailsForm"> <label for="pnr">PNR Number:</label> <input type="text" id="pnr" name="pnr" required> <label for="lastName">Last Name:</label> <input type="text" id="lastName" name="lastName" required> <button type="submit">Get Details</button> </form> <div id="passengerDetails" class="details-container"> <!-- Passenger details will be displayed here --> </div> </div> <script> // JavaScript Functionality document.getElementById('detailsForm').addEventListener('submit', function(event) { event.preventDefault(); const pnr = document.getElementById('pnr').value; const lastName = document.getElementById('lastName').value; // Simulate fetching data from an API fetchPassengerDetails(pnr, lastName) .then(data => { displayPassengerDetails(data); }) .catch(error => { console.error('Error:', error); alert('Failed to fetch passenger details. Please try again.'); }); }); function fetchPassengerDetails(pnr, lastName) { // Simulate an API call return new Promise((resolve, reject) => { setTimeout(() => { const mockData = { pnr: pnr, lastName: lastName, firstName: 'John', flightNumber: 'AA123', departure: 'New York (JFK)', destination: 'Los Angeles (LAX)', departureTime: '10:00 AM', arrivalTime: '1:00 PM', seatNumber: '24A', status: 'On Time' }; resolve(mockData); }, 1000); }); } function displayPassengerDetails(data) { const detailsContainer = document.getElementById('passengerDetails'); detailsContainer.innerHTML = ` <h2>Passenger Details</h2> <p><strong>PNR:</strong> ${data.pnr}</p> <p><strong>Name:</strong> ${data.firstName} ${data.lastName}</p> <p><strong>Flight Number:</strong> ${data.flightNumber}</p> <p><strong>Departure:</strong> ${data.departure}</p> <p><strong>Destination:</strong> ${data.destination}</p> <p><strong>Seat Number:</strong> ${data.seatNumber}</p> <p><strong>Status:</strong> ${data.status}</p> `; } </script> </body> </html>
Standard input is empty
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flight Passenger Details</title>
<style>
/* CSS Styling */
body, html {
margin: 0;
padding: 0;
height: 100%;
font-family: Arial, sans-serif;
}
.background-image {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('https://v...content-available-to-author-only...r.com/1920x1080'); /* Replace with your flight image */
background-size: cover;
background-position: center;
z-index: -1;
opacity: 0.7;
}
.container {
position: relative;
z-index: 1;
max-width: 600px;
margin: 50px auto;
padding: 20px;
background: rgba(255, 255, 255, 0.8);
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 5px;
font-weight: bold;
}
input {
margin-bottom: 15px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
.details-container {
margin-top: 20px;
padding: 20px;
background: rgba(255, 255, 255, 0.9);
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.details-container h2 {
margin-top: 0;
color: #333;
}
.details-container p {
margin: 5px 0;
color: #555;
}
</style>
</head>
<body>
<!-- HTML Structure -->
<div class="background-image"></div>
<div class="container">
<h1>Flight Passenger Details</h1>
<form id="detailsForm">
<label for="pnr">PNR Number:</label>
<input type="text" id="pnr" name="pnr" required>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" name="lastName" required>
<button type="submit">Get Details</button>
</form>
<div id="passengerDetails" class="details-container">
<!-- Passenger details will be displayed here -->
</div>
</div>
<script>
// JavaScript Functionality
document.getElementById('detailsForm').addEventListener('submit', function(event) {
event.preventDefault();
const pnr = document.getElementById('pnr').value;
const lastName = document.getElementById('lastName').value;
// Simulate fetching data from an API
fetchPassengerDetails(pnr, lastName)
.then(data => {
displayPassengerDetails(data);
})
.catch(error => {
console.error('Error:', error);
alert('Failed to fetch passenger details. Please try again.');
});
});
function fetchPassengerDetails(pnr, lastName) {
// Simulate an API call
return new Promise((resolve, reject) => {
setTimeout(() => {
const mockData = {
pnr: pnr,
lastName: lastName,
firstName: 'John',
flightNumber: 'AA123',
departure: 'New York (JFK)',
destination: 'Los Angeles (LAX)',
departureTime: '10:00 AM',
arrivalTime: '1:00 PM',
seatNumber: '24A',
status: 'On Time'
};
resolve(mockData);
}, 1000);
});
}
function displayPassengerDetails(data) {
const detailsContainer = document.getElementById('passengerDetails');
detailsContainer.innerHTML = `
<h2>Passenger Details</h2>
<p><strong>PNR:</strong> ${data.pnr}</p>
<p><strong>Name:</strong> ${data.firstName} ${data.lastName}</p>
<p><strong>Flight Number:</strong> ${data.flightNumber}</p>
<p><strong>Departure:</strong> ${data.departure}</p>
<p><strong>Destination:</strong> ${data.destination}</p>
<p><strong>Departure Time:</strong> ${data.departureTime}</p>
<p><strong>Arrival Time:</strong> ${data.arrivalTime}</p>
<p><strong>Seat Number:</strong> ${data.seatNumber}</p>
<p><strong>Status:</strong> ${data.status}</p>
`;
}
</script>
</body>
</html>