From 538f73bbb278407c656a62e1454d3e0bff486460 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 7 Oct 2025 10:17:57 -0300 Subject: [PATCH] id --- public/buyModal.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/public/buyModal.js b/public/buyModal.js index 7b9cc07..4a3614e 100644 --- a/public/buyModal.js +++ b/public/buyModal.js @@ -120,6 +120,7 @@ function createModal() { return modal; } + function openModal(productHref) { const modal = document.getElementById("buyNowModal"); modal.style.display = "flex"; @@ -154,11 +155,25 @@ function openModal(productHref) { locationSelect.value = ""; // reset } + // Set hidden inputs modal.querySelector('input[name="product"]').value = product; modal.querySelector('input[name="price"]').value = price; + + // Add or update hidden input for ID + let idInput = modal.querySelector('input[name="id"]'); + if (!idInput) { + idInput = document.createElement("input"); + idInput.type = "hidden"; + idInput.name = "id"; + form.appendChild(idInput); + } + idInput.value = id; + modal.querySelector("#productText").textContent = `You will buy ${product} for $${price}.`; } + + function handleFormSubmit() { const form = document.getElementById("buyForm"); const confirmation = document.getElementById("confirmation");