For my project, I am required to develop a functional shopping cart with a remove function. If an item is already in the cart, it should update the existing data when added again.
Let's say I have the following items in my cart:
Name: Quantity: Price: Total: Potato 1 1 1
Using a table to display this cart, if I select another potato from a dropdown list, I want to update the quantity and total of the existing potato in the cart to become 2 and 2 respectively. I've been stuck on this problem for hours now without making any progress towards a solution.
Below is the current code that adds items to the table:
"use strict"; const btn = document.getElementById('toevoegen'); ...
In addition, here is the HTML code as requested:
<!DOCTYPE html> <html lang="nl"> ...
I have implemented a function to check if the selected item from the dropdown list already exists in the table. However, I'm unsure how to target a specific cell within the table to perform this check.
Suppose I choose potato,
I want to verify if there is already an item named potato in my table, and if so, update the quantity and total of that item accordingly.
Is this achievable?