From d5cdfe91335af6c79231d41453991af29a39e96e Mon Sep 17 00:00:00 2001 From: adityacp Date: Sat, 25 Apr 2020 10:57:51 +0530 Subject: Add a search bar to search users --- yaksh/templates/yaksh/grade_user.html | 36 ++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html index 14666e1..f4c7d67 100644 --- a/yaksh/templates/yaksh/grade_user.html +++ b/yaksh/templates/yaksh/grade_user.html @@ -15,7 +15,24 @@ $(document).ready(function() { $("#marks_table").tablesorter({sortList: [[2,1]]}); }); +function searchNames() { + var input, filter, ul, li, a, i, txtValue; + input = document.getElementById('myInput'); + filter = input.value.toUpperCase(); + $("#myUL").toggle(); + ul = document.getElementById("myUL"); + li = ul.getElementsByTagName('li'); + for (i = 0; i < li.length; i++) { + a = li[i].getElementsByTagName("a")[0]; + txtValue = a.textContent || a.innerText; + if (txtValue.toUpperCase().indexOf(filter) > -1) { + li[i].style.display = ""; + } else { + li[i].style.display = "none"; + } + } +} {% endblock script %} @@ -92,8 +109,8 @@ $(document).ready(function() @@ -112,7 +129,6 @@ $(document).ready(function() {% endif %}