New paste Repaste Download
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Train Registration</title>
  <style>
    body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f9f9f9;
  margin: 0;
  padding: 0;
}
  /* Navigation Bar */
  nav {
      background-color: #1e3a8a;
      padding: 15px 30px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }
    nav a {
      color: white;
      text-decoration: none;
      margin: 0 12px;
      padding: 8px 16px;
      border-radius: 5px;
      transition: background 0.3s ease;
    }
    nav a:hover {
      background-color: #3b82f6;
    }
.container {
  max-width: 600px;
  margin: 40px auto;
  padding: 30px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}
h2, h3 {
  text-align: center;
  color: #333;
}
.form-group {
  margin-bottom: 20px;
}
label {
  display: block;
  font-weight: bold;
  margin-bottom: 8px;
}
input, select {
  width: 100%;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid #ccc;
}
button {
  width: 100%;
  padding: 12px;
  background-color: #007BFF;
  color: #fff;
  font-size: 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
button:hover {
  background-color: #0056b3;
}
.preview {
  margin-top: 30px;
  padding: 20px;
  background-color: #eef;
  border-radius: 8px;
  font-size: 15px;
}
  </style>
</head>
<body>
    <nav>
        <div>
          <a href="index.html">Home</a>
          <a href="register-train.html">Register a Train</a>
          <a href="profile.html">Profile</a>
        </div>
        <a href="index.html">Logout</a>
      </nav>
    
  <div class="container">
    <h2>Register a Train</h2>
    <form id="trainForm">
      <div class="form-group">
        <label for="trainName">Train Name:</label>
        <input type="text" id="trainName" required>
      </div>
      <div class="form-group">
        <label for="seats">Number of Seats:</label>
        <input type="number" id="seats" min="1" required>
      </div>
      <div class="form-group">
        <label for="from">From:</label>
        <input type="text" id="from" required>
      </div>
      <div class="form-group">
        <label for="to">To:</label>
        <input type="text" id="to" required>
      </div>
      <div class="form-group">
        <label for="ownership">Ownership:</label>
        <select id="ownership" required>
          <option value="">Select Ownership</option>
          <option value="Government">Government</option>
          <option value="Private">Private</option>
          <option value="Public-Private">Public-Private</option>
        </select>
      </div>
      <button type="submit">Register Train</button>
    </form>
    <div id="preview" class="preview">
      <h3>Train Preview</h3>
      <p id="previewContent">Fill out the form to see preview.</p>
    </div>
  </div>
  <script >
    const form = document.getElementById("trainForm");
const previewContent = document.getElementById("previewContent");
// Update preview as user types
form.addEventListener("input", () => {
  const name = document.getElementById("trainName").value;
  const seats = document.getElementById("seats").value;
  const from = document.getElementById("from").value;
  const to = document.getElementById("to").value;
  const ownership = document.getElementById("ownership").value;
  previewContent.innerHTML = `
    <strong>Train Name:</strong> ${name || "-"}<br>
    <strong>Seats:</strong> ${seats || "-"}<br>
    <strong>From:</strong> ${from || "-"}<br>
    <strong>To:</strong> ${to || "-"}<br>
    <strong>Ownership:</strong> ${ownership || "-"}
  `;
});
// Handle form submission
form.addEventListener("submit", function (e) {
  e.preventDefault();
  const trainData = {
    name: document.getElementById("trainName").value,
    seats: parseInt(document.getElementById("seats").value),
    from: document.getElementById("from").value,
    to: document.getElementById("to").value,
    ownership: document.getElementById("ownership").value
  };
  if (trainData.seats <= 0) {
    alert("Please enter a valid number of seats.");
    return;
  }
  console.log("Train registered:", trainData);
  alert("Train registered successfully!");
  form.reset();
  previewContent.innerHTML = "Fill out the form to see preview.";
});
  </script>
</body>
</html>
Filename: None. Size: 5kb. View raw, , hex, or download this file.

This paste expires on 2025-05-13 04:44:15.942728. Pasted through web.