projetphp/views/table.html.twig

71 lines
1.8 KiB
Twig
Executable File

<html>
<head>
{% include 'header.html.twig' %}
</head>
<body>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names..">
<table id="allRecord">
<thead>
<tr>
<th>login</th>
<th>Date de nésance</th>
<th>email</th>
<th>PW</th>
<th>slvl</th>
<th><i class="fas fa-cogs"></i></th>
</tr>
</thead>
<tbody>
{% for data in datas %}
<tr class="record">
<td class="login">
{{ data["login"] }}
</td>
<td class="datene">
{{ data["date_naissance"] }}
</td>
<td class="email">
{{ data["e_mail"] }}
</td>
<td class="pw">
{{ data["mot_de_passe"] }}
</td>
<td class="sl">
{{ data["security_level"] }}
</td>
<td><i class="fas fa-edit click editUser"></i><i class="fas fa-trash-alt click delUser"></i></td>
</tr>
{% endfor %}
<tr rowspan="2">
<td colspan="6" style="text-align:center"><i class="fas fa-user-plus fa-4x click"></i></td>
</tr>
</tbody>
</table>
</body>
<script>
//https://www.w3schools.com/howto/howto_js_filter_table.asp
function myFunction() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("allRecord");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</html>