Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by NycBestTransfers

  1. Hello, I'm having some issues with my landing page not redirecting to the final summary page when selecting the book option on the type of vehicle is chosen. have verified ID's and seems to be correct but still not redirecting from the landing page to summary page. redirecting from the home page to the landing page works like a charm and does exactly what I need it to do. any help would be appreciated... If you visit the website, run the example route JFK to Brooklyn and that should take you over to the landing page that is setup with the code to redirect to the summary page but for some reason it is redirecting right back to the landing page with all information correct. home page: www.nycbesttransfers.com/home landing page: www.nycbesttransfers.com/jfk-to-brooklyn final page: www.nycbesttransfers.com/your-booking-summary home page code: <script> document.addEventListener('DOMContentLoaded', function () { var form = document.getElementById('block-yui_3_17_2_1_1697644696480_9794'); // Ensure this is your form's ID form.addEventListener('submit', function (event) { event.preventDefault(); // Get selected values from the form var departure = document.getElementById('select-77808fe4-56aa-4e81-9c83-ca7abca1f60a-field').value; // Replace 'departure' with your actual dropdown ID var destination = document.getElementById('select-1d2a9775-fe1f-4665-819d-43e8da02c217-field').value; // Replace 'destination' with your actual dropdown ID // Get additional form values (number of passengers, date, and time) var passengers = document.getElementById('select-7a5a03a0-5f29-40c6-a165-3fd5a957760b-field').value; // Replace with your actual field ID var date = document.getElementById('date-e14f3396-dad4-4ecf-a8b8-5ca6b5f929fe-field').value; // Replace with your actual field ID var time = document.getElementById('time-eaf91c4e-4554-45d2-be45-9a2554127f89-field').value; // Replace with your actual field ID var roundtrip = document.getElementById('select-19011c7f-747e-40ba-abbb-6704e4e0b582-field').value; // Replace with your actual field ID // Define redirection URLs based on selected options var redirectionMap = { 'JFK Airport to Brooklyn': '/jfk-to-brooklyn', 'JFK Airport to Bronx': '/jfk-to-bronx', 'JFK Airport to Manhattan': '/jfk-to-manhattan', 'JFK Airport to Queens': '/jfk-to-queens', 'JFK Airport to New Jersey': '/jfk-to-new-jersey', 'LaGuardia Airport to Brooklyn': '/laguardia-to-brooklyn', 'LaGuardia Airport to Bronx': '/laguardia-to-bronx', 'LaGuardia Airport to Manhattan': '/laguardia-to-manhattan', 'LaGuardia Airport to Queens': '/laguardia-to-queens', 'LaGuardia Airport to New Jersey': '/laguardia-to-new-jersey', 'Newark Airport to Brooklyn': '/newark-to-brooklyn', 'Newark Airport to Bronx': '/newark-to-bronx', 'Newark Airport to Manhattan': '/newark-to-manhattan', 'Newark Airport to Queens': '/newark-to-queens', 'Newark Airport to New Jersey': '/newark-to-new-jersey', 'Brooklyn to JFK Airport': '/brooklyn-to-jfk', 'Brooklyn to LaGuardia Airport': '/brooklyn-to-laguardia', 'Brooklyn to Newark Airport': '/brooklyn-to-newark', 'Bronx to JFK Airport': '/bronx-to-jfk', 'Bronx to LaGuardia Airport': '/bronx-to-laguardia', 'Bronx to Newark Airport': '/bronx-to-newark', 'Manhattan to JFK Airport': '/manhattan-to-jfk', 'Manhattan to LaGuardia Airport': '/manhattan-to-laguardia', 'Manhattan to Newark Airport': '/manhattan-to-newark', 'Queens to JFK Airport': '/queens-to-jfk', 'Queens to LaGuardia Airport': '/queens-to-laguardia', 'Queens to Newark Airport': '/queens-to-newark', 'New Jersey to JFK Airport': '/new-jersey-to-jfk', 'New Jersey to LaGuardia Airport': '/new-jersey-to-laguardia', 'New Jersey to Newark Airport': '/new-jersey-to-newark', // ... (keep the map as it is) }; // Build the redirection URL based on selected options var key = departure + ' to ' + destination; var redirectionURL = redirectionMap[key]; // If redirection URL exists, add query parameters for selected information if (redirectionURL) { var queryParams = `?departure=${departure}&destination=${destination}&passengers=${passengers}&date=${date}&time=${time}&roundtrip=${roundtrip}`; window.location.href = redirectionURL + queryParams; } else { console.error('No redirection URL found for the selected options.'); } }); }); </script> Landing page code: <script> function getQueryParam(name) { var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); if (results == null) { return null; } return decodeURIComponent(results[1]) || 0; } document.addEventListener('DOMContentLoaded', function () { var departure = getQueryParam('departure'); var destination = getQueryParam('destination'); var date = getQueryParam('date'); var time = getQueryParam('time'); var passengers = getQueryParam('passengers'); var roundtrip = getQueryParam('roundtrip'); var detailsDiv = document.getElementById('block-yui_3_17_2_1_1698265778966_8086'); detailsDiv.innerHTML = ` <strong>Pick up:</strong> ${departure} <br> <strong>Drop off:</strong> ${destination} <br> <strong>Date:</strong> ${date} <br> <strong>Time:</strong> ${time} <br> <strong>Number of Passengers:</strong> ${passengers} <br> <strong>Roundtrip:</strong> ${roundtrip} <br> `; // Add event listeners to the "Book" buttons for each vehicle var sedanButton = document.getElementById('yui_3_17_2_1_1698672893506_1092'); sedanButton.addEventListener('click', function () { redirectToSummary('Sedan'); }); var suvButton = document.getElementById('yui_3_17_2_1_1698672893506_1587'); suvButton.addEventListener('click', function () { redirectToSummary('SUV'); }); var limoButton = document.getElementById('yui_3_17_2_1_1698672893506_11069'); limoButton.addEventListener('click', function () { redirectToSummary('Limo'); }); function redirectToSummary(selectedVehicle) { // Redirect to the final summary page with the selected vehicle window.location.href = `/your-booking-summary?departure=${departure}&destination=${destination}&date=${date}&time=${time}&passengers=${passengers}&roundtrip=${roundtrip}&vehicle=${selectedVehicle}`; } }); </script> Final Page code: document.addEventListener('DOMContentLoaded', function () { var url = new URL(window.location.href); var searchParams = new URLSearchParams(url.search); var departure = searchParams.get('departure'); var destination = searchParams.get('destination'); var date = searchParams.get('date'); var time = searchParams.get('time'); var passengers = searchParams.get('passengers'); var roundtrip = searchParams.get('roundtrip'); var vehicle = searchParams.get('vehicle'); // Display the selected information on the final page var finalPageDiv = document.getElementById('block-3618468c8fe661062fe3'); finalPageDiv.innerHTML = ` <strong>Pick up:</strong> ${departure} <br> <strong>Drop off:</strong> ${destination} <br> <strong>Date:</strong> ${date} <br> <strong>Time:</strong> ${time} <br> <strong>Number of Passengers:</strong> ${passengers} <br> <strong>Roundtrip:</strong> ${roundtrip} <br> <strong>Selected Vehicle:</strong> ${vehicle} <br> `; // You can also handle payment processing using Square on this page if needed. } });
  2. Hello, Im looking to setup a form similar to the website I have listed below. I would like to setup the form so clients can choose a dropdown and it will redirect to the correct page depending on the type of selection of pick up location and drop off location which will then show them what vehicles we have and price of the travel. Thanks in advance. Form Example
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.