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

View File

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