New paste Repaste Download
document.getElementById("bookingForm").addEventListener("submit", function(e) {
  e.preventDefault();
  const from = document.getElementById("fromCity").value;
  const to = document.getElementById("toCity").value;
  const resultsBody = document.getElementById("resultsBody");
  // Clear previous results
  resultsBody.innerHTML = "";
  // Simple check
  if (!from || !to || from === to) {
    alert("Please select valid different cities for From and To.");
    return;
  }
  // Dummy data - Replace with real data if needed
  const trainData = [
    { name: "Vande Bharat Express", number: "22436", tickets: 80 },
    { name: "Shatabdi Express", number: "12001", tickets: 42 },
    { name: "Rajdhani Express", number: "12951", tickets: 57 }
  ];
  // Populate table
  trainData.forEach(train => {
    const row = `<tr>
      <td>${train.name}</td>
      <td>${train.number}</td>
      <td>${train.tickets}</td>
    </tr>`;
    resultsBody.innerHTML += row;
  });
  document.getElementById("trainResults").style.display = "block";
});
function swapCities() {
  const from = document.getElementById("fromCity");
  const to = document.getElementById("toCity");
  const temp = from.value;
  from.value = to.value;
  to.value = temp;
}
Filename: None. Size: 1kb. View raw, , hex, or download this file.

This paste expires on 2025-05-13 05:41:19.781249. Pasted through web.