I want help with this code. It does not give any error and does not perform any action when pressing the button
export function Addtocart_click(event,$w) {
let name = $w("#category").value;
let size = $w("#productsize").value;
let quantity = $w("#quantity").value;
$w('#dataset2').setFieldValue('name', name);
$w('#dataset2').setFieldValue('size', size);
$w('#dataset2').setFieldValue('quantity', quantity);
$w("#dataset2").onAfterSave(() => {
$w("#repeater1").onItemReady(($item, itemData, index) => {
$item("#text87").text = itemData.name;
$item("#text88").text = itemData.size;
$item("#text91").text = itemData.quantity;
});
wixData.query("Addtocart")
.find()
.then((result) => {
$w("#repeater1").data = result.items;
let sumTotal = 0; // declare sum
result.items.forEach(item => {
sumTotal = sumTotal + Number(item.quantity);
console.log(sumTotal);
});
$w("#text86").text = "" + sumTotal;
});
});
}
thank you very much, its work
Hi Rima,
I was able to find an example that is similar to what you are trying to accomplish here. The example accepts an input and then displays it in a repeater after the Enter key is pressed. In your scenario, you will want to use a button instead since you are coding a form. Take a look at the example and open the template to see the code. You can then adapt the example's code to what you are trying to do and see if that works fine with you.
Hope this helps!
Edward | Corvid Team