diff --git a/public/buyModal.js b/public/buyModal.js index 30db84c..db81ef9 100644 --- a/public/buyModal.js +++ b/public/buyModal.js @@ -131,13 +131,6 @@ function openModal(productHref) { product = parts[parts.length - 2] || "Product"; price = parts[parts.length - 1] || "0"; } - - product = product.replace(/_/g, ""); - - modal.querySelector('input[name="product"]').value = product; - modal.querySelector('input[name="price"]').value = price; - modal.querySelector("#productText").textContent = `You will buy ${product} for $${price}.`; - // Show/hide location select const locationSelect = document.getElementById("locationSelect"); if (product.startsWith("_")) { @@ -148,8 +141,14 @@ function openModal(productHref) { locationSelect.removeAttribute("required"); locationSelect.value = ""; // reset } + product = product.replace(/_/g, ""); // This needs to be after the locationSelect show ;) + + modal.querySelector('input[name="product"]').value = product; + modal.querySelector('input[name="price"]').value = price; + modal.querySelector("#productText").textContent = `You will buy ${product} for $${price}.`; } + function handleFormSubmit() { const form = document.getElementById("buyForm"); const confirmation = document.getElementById("confirmation");