From a69a1bbfb3bea71f3d89a07a1be1c3bc0f0ea2ea Mon Sep 17 00:00:00 2001
From: 65160270 <65160270@go.buu.ac.th>
Date: Tue, 25 Mar 2025 16:35:10 +0700
Subject: [PATCH] update-server

---
 views/cart.ejs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/views/cart.ejs b/views/cart.ejs
index 896407c..5898e68 100644
--- a/views/cart.ejs
+++ b/views/cart.ejs
@@ -63,8 +63,10 @@
             </div>
 
             <script>
+                // อัปเดตจำนวนสินค้า
                 document.querySelectorAll(".update-btn").forEach(button => {
                     button.addEventListener("click", async (event) => {
+                        event.stopPropagation(); // ป้องกันการรบกวนกับปุ่มอื่น
                         const cartItem = event.target.closest(".cart-item");
                         const cartItemId = cartItem.dataset.id;
                         const quantity = cartItem.querySelector("input[name='quantity']").value;
@@ -82,6 +84,19 @@
                         }
                     });
                 });
+            
+                // เปิดปุ่ม Remove เมื่อกด Edit
+                document.querySelectorAll(".edit-btn").forEach(button => {
+                    button.addEventListener("click", (event) => {
+                        event.stopPropagation(); // ป้องกัน event ซ้อนทับ
+                        const cartItem = event.target.closest(".cart-item");
+                        const removeForm = cartItem.querySelector(".remove-form");
+                        const editButton = cartItem.querySelector(".edit-btn");
+            
+                        editButton.style.display = "none";  // ซ่อนปุ่ม Edit
+                        removeForm.style.display = "block"; // แสดงปุ่ม Remove
+                    });
+                });
             </script>
         <% } %>
     </div>
-- 
GitLab