From 84289369643c4b135437d1fd7245c049c7c9af0d Mon Sep 17 00:00:00 2001 From: 65160111 <65160111@go.buu.ac.th> Date: Mon, 24 Mar 2025 19:43:47 +0700 Subject: [PATCH] script.js getElementById --- public/script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index 0031864..59b2e6a 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"; -- GitLab