id
This commit is contained in:
@@ -120,6 +120,7 @@ function createModal() {
|
|||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openModal(productHref) {
|
function openModal(productHref) {
|
||||||
const modal = document.getElementById("buyNowModal");
|
const modal = document.getElementById("buyNowModal");
|
||||||
modal.style.display = "flex";
|
modal.style.display = "flex";
|
||||||
@@ -154,11 +155,25 @@ function openModal(productHref) {
|
|||||||
locationSelect.value = ""; // reset
|
locationSelect.value = ""; // reset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set hidden inputs
|
||||||
modal.querySelector('input[name="product"]').value = product;
|
modal.querySelector('input[name="product"]').value = product;
|
||||||
modal.querySelector('input[name="price"]').value = price;
|
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}.`;
|
modal.querySelector("#productText").textContent = `You will buy ${product} for $${price}.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function handleFormSubmit() {
|
function handleFormSubmit() {
|
||||||
const form = document.getElementById("buyForm");
|
const form = document.getElementById("buyForm");
|
||||||
const confirmation = document.getElementById("confirmation");
|
const confirmation = document.getElementById("confirmation");
|
||||||
|
|||||||
Reference in New Issue
Block a user