From 271e0db9e956612d93e0884030249d421c2a4da9 Mon Sep 17 00:00:00 2001 From: Sewaaa Date: Sat, 30 Dec 2023 19:03:57 +0100 Subject: [PATCH] SearchBar --- .../java/controller/homeTherapistServlet.java | 1 + src/main/webapp/CSS/homeTherapist.css | 16 +++++++-- src/main/webapp/JS/searchBar.js | 25 +++++++++++++ src/main/webapp/JSP/homeTherapist.jsp | 4 +++ src/main/webapp/JSP/testTable.jsp | 35 +++++++++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/main/webapp/JS/searchBar.js diff --git a/src/main/java/controller/homeTherapistServlet.java b/src/main/java/controller/homeTherapistServlet.java index 5631a26..20c7f4e 100644 --- a/src/main/java/controller/homeTherapistServlet.java +++ b/src/main/java/controller/homeTherapistServlet.java @@ -39,6 +39,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t session.setAttribute("NameSurnameLogged",InfoLogged.getFirstname()+" "+InfoLogged.getLastname()); response.sendRedirect("JSP/homeTherapist.jsp"); + //response.sendRedirect("JSP/testTable.jsp"); } diff --git a/src/main/webapp/CSS/homeTherapist.css b/src/main/webapp/CSS/homeTherapist.css index ed19b9b..5147785 100644 --- a/src/main/webapp/CSS/homeTherapist.css +++ b/src/main/webapp/CSS/homeTherapist.css @@ -1,3 +1,15 @@ +/* Stile per la barra di ricerca */ +#searchInput { + padding: 8px; + border: 0px; + position: absolute; + width: 70%; + top: 10px; + left: 50px; + outline: none; +} + + .table-container { max-height: 350px; /* Altezza massima della tabella */ overflow-y: auto; /* Rendi scorrevole solo l'asse Y quando necessario */ @@ -5,8 +17,8 @@ table { width: 100%; - border-collapse: collapse; - border-spacing: 0 35px; /* Imposta uno spazio vuoto tra le righe */ + border-collapse: separate; + border-spacing: 0 10px; /* Imposta uno spazio vuoto tra le righe */ } tr { diff --git a/src/main/webapp/JS/searchBar.js b/src/main/webapp/JS/searchBar.js new file mode 100644 index 0000000..4b15710 --- /dev/null +++ b/src/main/webapp/JS/searchBar.js @@ -0,0 +1,25 @@ +//search bar for name and surname +$(document).ready(function () { + var tableContainer = document.getElementById('tableContainer'); + + // Aggiungi un gestore di eventi all'input di ricerca + $('#searchInput').on('input', function () { + var searchText = $(this).val().toLowerCase(); + + // Nascondi tutte le righe + tableContainer.getElementsByTagName('tbody')[0].style.marginTop = '0'; + + // Filtra e mostra solo le righe che corrispondono alla ricerca + $('tbody tr').each(function () { + var name = $(this).find('td:eq(1)').text().toLowerCase(); + var lastName = $(this).find('td:eq(2)').text().toLowerCase(); + + if (name.includes(searchText) || lastName.includes(searchText)) { + $(this).show(); + } else { + $(this).hide(); + } + }); + }); + +}); \ No newline at end of file diff --git a/src/main/webapp/JSP/homeTherapist.jsp b/src/main/webapp/JSP/homeTherapist.jsp index 3059c71..9028175 100644 --- a/src/main/webapp/JSP/homeTherapist.jsp +++ b/src/main/webapp/JSP/homeTherapist.jsp @@ -5,6 +5,7 @@ + @@ -16,6 +17,7 @@
+
PAZIENTI
@@ -113,10 +115,12 @@
+
+ \ No newline at end of file diff --git a/src/main/webapp/JSP/testTable.jsp b/src/main/webapp/JSP/testTable.jsp index 05b0091..9bec059 100644 --- a/src/main/webapp/JSP/testTable.jsp +++ b/src/main/webapp/JSP/testTable.jsp @@ -4,6 +4,8 @@ + +