diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/FormMaker.iml b/.idea/FormMaker.iml
new file mode 100644
index 0000000..5e764c4
--- /dev/null
+++ b/.idea/FormMaker.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..0982d8b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/index.html b/index.html
index da37a5f..6f81081 100644
--- a/index.html
+++ b/index.html
@@ -27,7 +27,7 @@
-
+
diff --git a/main.go b/main.go
index 8510555..1f19363 100644
--- a/main.go
+++ b/main.go
@@ -46,6 +46,9 @@ func handleFormSubmit(w http.ResponseWriter, r *http.Request) {
return
}
+ // Log all form data
+ log.Printf("[DEBUG] Form data: %v\n", r.Form)
+
name := r.FormValue("name")
email := r.FormValue("email")
phone := r.FormValue("phone")
diff --git a/static/util.js b/static/util.js
index 2cde80a..faa809e 100644
--- a/static/util.js
+++ b/static/util.js
@@ -41,7 +41,6 @@ document.addEventListener('DOMContentLoaded', function () {
const tagsInput = document.getElementById('classes-input');
let classes = [];
- // Define the addClass function before it's used
function addClass(classname) {
const container = document.getElementById('classes-container');
const classElement = document.createElement('span');
@@ -54,74 +53,35 @@ document.addEventListener('DOMContentLoaded', function () {
closeIcon.addEventListener('click', function () {
container.removeChild(classElement);
classes = classes.filter(c => c !== classname);
- fetchMatchingPeople(classes); // Call fetchMatchingPeople when a class is removed
});
classElement.appendChild(closeIcon);
container.appendChild(classElement);
}
- // Define the fetchMatchingPeople function before it's used
- function fetchMatchingPeople(classes) {
- const xhr = new XMLHttpRequest();
- xhr.open("POST", "/fetch-matches", true);
- xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
-
- xhr.onload = function () {
- if (xhr.status === 200) {
- const matchesContainer = document.getElementById('matches-container');
- const people = JSON.parse(xhr.responseText);
-
- matchesContainer.innerHTML = '';
-
- // Log the response to see if "people" is populated
- console.log("Fetched people: ", people);
-
- if (people && people.length > 0) {
- people.forEach(person => {
- const personDiv = document.createElement('div');
- personDiv.classList.add('person');
- personDiv.innerHTML = `${person.name}
Classes: ${person.classes.join(', ')}
Email: ${person.email || 'N/A'}`;
- matchesContainer.appendChild(personDiv);
- });
- } else {
- matchesContainer.innerHTML = 'No matches found for these classes.
';
- }
- } else {
- console.error("Error fetching matches:", xhr.status, xhr.responseText);
- }
- };
-
- xhr.onerror = function () {
- console.error("Network error while fetching matches.");
- };
-
- xhr.send(JSON.stringify({ classes: classes }));
- }
-
tagsInput.addEventListener('keydown', function (event) {
if (event.key === 'Enter' || event.key === ',') {
event.preventDefault();
let value = tagsInput.value.trim().replace(/,$/, '');
- if (value) {
- addClass(value); // Add class tag
- classes.push(value); // Add to classes array
- fetchMatchingPeople(classes); // Fetch matching people
- tagsInput.value = '';
+ if (value && !classes.includes(value)) { // Check for empty and duplicate values
+ addClass(value);
+ classes.push(value);
+ tagsInput.value = ''; // Clear the input
}
}
});
document.querySelector('form').addEventListener('submit', function (event) {
- console.log('Classes on submit:', classes);
const hiddenClassesInput = document.createElement('input');
hiddenClassesInput.type = 'hidden';
hiddenClassesInput.name = 'classes';
- // Filter out empty class names and trim spaces
const cleanedClasses = classes.filter(classname => classname.trim() !== "").map(classname => classname.trim());
hiddenClassesInput.value = cleanedClasses.join(',');
-
+
+ console.log("Hidden input value being submitted: ", hiddenClassesInput.value); // Log the value
+
this.appendChild(hiddenClassesInput);
+ console.log("Form data before submission: ", new FormData(this)); // Log the form data
});
});