Open Georgeikani opened 3 months ago
use the valuable name of the dataset (productId) in the querySelector, example below.
//product quantity
const quantitySelector = document.querySelector(.js-quantity-selector-${productId}
).value;
const covertToNumber = Number(quantitySelector);
use the valuable name of the dataset (productId) in the querySelector, example below.
//product quantity const quantitySelector = document.querySelector(
.js-quantity-selector-${productId}
).value; const covertToNumber = Number(quantitySelector);
please are you sure this code works cos i have tried that so many times and i am still not getting the results
this is the HTML
and this the JavaScript
const cartInputQuantity = document.querySelector(.js-cart-quantity-input-${productId}
).value;
let newQuantity = Number(cartInputQuantity);
actually, i don't know how you sent your code.
here is the complete code, starting from the 'save link'.
the save link, i use selectAll, in the 'save link' gave it a data-set (e.g, data-product-id=${matchingProduct.id}).
use the variable name you use for the dataset ( e.g, const productId = saveCartQuantity.dataset.productId;), use the variable name in your input (e.g, const cartInputQuantity = document.querySelector(.js-cart-quantity-input-${productId}
).value;)
//--------------------------Javascript document.querySelectorAll('.js-save-cart-quantity') .forEach((saveCartQuantity)=>{ saveCartQuantity.addEventListener('click',()=>{ const productId = saveCartQuantity.dataset.productId;
const cartInputQuantity = document.querySelector(`.js-cart-quantity-input-${productId}`).value;
let newQuantity = Number(cartInputQuantity);
});
});
Hi Okontg thanks for helping out, but it was resolve. is there any means i can reach you either mail or whatsapp i'd really appreciate it
id: "e43638ce-6aa0-4b85-b27f-e1d07eb678c6", },
is how to generate the id i meant
How do i generate the Id in product.js. Const product = [{ id: name: }]