<script> document.addEventListener("DOMContentLoaded", function () { // Target the form on the page const form = document.querySelector("form[data-form-id]"); form.addEventListener("submit", function (e) { e.preventDefault(); // Prevents default form submission // Capture form field values by exact IDs (replace these with actual IDs from your Squarespace form) const firstName = encodeURIComponent(document.getElementById("name-yui_3_17_2_1_1730915569241_946-fname-field").value); const lastName = encodeURIComponent(document.getElementById("name-yui_3_17_2_1_1730915569241_946-lname-field").value); const email = encodeURIComponent(document.getElementById("email-yui_3_17_2_1_1730915569241_947-field").value); const bodyweight = encodeURIComponent(document.getElementById("number-b160eba5-e012-4c20-87a8-7900a34da635-field").value); const age = encodeURIComponent(document.getElementById("number-0bab7c43-80d7-4d17-a081-95b3d24f10da-field").value); const height = encodeURIComponent(document.getElementById("number-1802120b-5728-492a-82bb-6ba5ce878015-field").value); const gender = encodeURIComponent(document.getElementById("select-f9ac5a3b-ba33-4d15-8010-2c531f61f48f-field").value); // Construct the redirect URL with query parameters const redirectUrl = `/thank-you?firstName=${firstName}&lastName=${lastName}&email=${email}&bodyweight=${bodyweight}&age=${age}&height=${height}&gender=${gender}`; window.location.href = redirectUrl; }); }); </script>