From 0685312a845067007370caa09318baacd66bbeb0 Mon Sep 17 00:00:00 2001 From: overplayed <47672088+overplayed@users.noreply.github.com> Date: Sat, 15 Mar 2025 23:28:24 -0400 Subject: [PATCH] Fixed paths in main.js and added toggleOtherField function --- assets/js/main.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 6512db4..ad25fe5 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,6 +1,6 @@ document.addEventListener("DOMContentLoaded", function () { // 🚀 Automatically load existing responses if available - fetch("load-responses.php") + fetch("./load-responses.php") .then(response => response.json()) .then(data => prepopulateForm(data)) .catch(error => console.error("Failed to load form responses:", error)); @@ -11,7 +11,7 @@ document.addEventListener("DOMContentLoaded", function () { const formData = new FormData(this); - fetch("submit.php", { + fetch("./submit.php", { method: "POST", body: formData }) @@ -95,3 +95,11 @@ function toggleDependentFields() { }); }); } + +function toggleOtherField(checkbox, targetId) { + let target = document.getElementById(targetId); + if (target) { + target.style.display = checkbox.checked ? "block" : "none"; + } +} +