Search update

This commit is contained in:
RochesterX
2025-11-26 23:55:37 -05:00
parent 394946234d
commit 24abf00162
2 changed files with 24 additions and 5 deletions

View File

@@ -20,7 +20,7 @@
<option value="CreatedAt">Date Created</option>
</select>
<p>Search players by name:</p>
<input type="text" id="query" placeholder="Contains" required>
<input type="text" id="query" placeholder="Contains">
<div class="days">
@@ -43,7 +43,7 @@
</div>
<button type="submit">Search</button>
<button style="display: none;" type="submit">Search</button>
</form>
<table id="table">

View File

@@ -12,8 +12,28 @@ const nomatch = document.getElementById("nomatch");
updateTableVisibility();
if (searchForm)searchForm.onsubmit = async e => {
document.querySelectorAll("input[type='checkbox']").forEach(checkbox => {
checkbox.addEventListener("change", e => {
e.preventDefault();
updateSearch();
});
});
document.querySelectorAll("input[type='text']").forEach(checkbox => {
checkbox.addEventListener("change", e => {
e.preventDefault();
updateSearch();
});
});
if (searchForm)searchForm.onsubmit = e => {
e.preventDefault();
updateSearch();
};
updateSearch();
async function updateSearch () {
if (!verifyLogin()) return;
const formData = new FormData(searchForm);
@@ -25,7 +45,7 @@ if (searchForm)searchForm.onsubmit = async e => {
}
let resultObject = await postData("/getPlayers", {
player: document.getElementById("query").value,
player: document.getElementById("query").value || "%",
positions: positions
}, token);
@@ -53,7 +73,6 @@ if (searchForm)searchForm.onsubmit = async e => {
tableBody.innerHTML = "";
resultObject.matches.forEach(player => {
const row = document.createElement("tr");
console.log(player);
//for (attribute in player) {
// row.innerHTML += `<td>${player}</td>l`;