Skip to content

Commit

Permalink
Created a function to handle deleting an item from the cart
Browse files Browse the repository at this point in the history
  • Loading branch information
DiksonIvySon committed Oct 18, 2023
1 parent 80be30e commit 6e6061c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions landingPage/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ function display_cartList() {
<div>
<span><strong>PRICE: </strong>R${cartList[i].price}</span>
</div>
<button role="button" class="remove-btn">REMOVE</button>
<button role="button" class="remove-btn" onclick="deleteCartItem(${i})">REMOVE</button>
</div>
`

cartItem_container.appendChild(cart_Item);
}
}
}

//function to handle deleting an item from the cart
function deleteCartItem(index) {
cartList.splice(index, 1);
display_cartList();
}
2 changes: 1 addition & 1 deletion landingPage/store.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ <h2>CART</h2>
<div>
<span><strong>PRICE: </strong>R500</span>
</div>
<button role="button" class="remove-btn">REMOVE</button>
<button role="button" class="remove-btn" onclick="">REMOVE</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 6e6061c

Please sign in to comment.