diff --git a/public/script.js b/public/script.js index 00318648eede01c452d95cb494ead4ad1f0dae27..59b2e6acda807b467cd26a1a7c4c7ab3666af110 100644 --- a/public/script.js +++ b/public/script.js @@ -344,10 +344,11 @@ function loadEditReport() { // 🔹 ส่งข้อมูลที่แก้ไขไปอัปเดตในฐานข้อมูล (สำหรับ edit_report.html) document.getElementById("editReportForm")?.addEventListener("submit", function(event) { event.preventDefault(); - + const reportId = document.getElementById("reportId").value; const title = document.getElementById("editTitle").value; const description = document.getElementById("editDescription").value; + const room_id = document.getElementById("room").value; // อ่านค่าจาก dropdown ห้อง fetch(`${API_URL}/reports/${reportId}`, { method: "PUT", @@ -355,7 +356,7 @@ document.getElementById("editReportForm")?.addEventListener("submit", function(e "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` }, - body: JSON.stringify({ title, description }) + body: JSON.stringify({ title, description, room_id }) }) .then(res => res.json()) .then(data => { @@ -365,6 +366,7 @@ document.getElementById("editReportForm")?.addEventListener("submit", function(e .catch(error => console.error("❌ Update Report Error:", error)); }); + // 🔹 ยกเลิกการแก้ไข (สำหรับ edit_report.html) function cancelEdit() { window.location.href = "dashboard.html";