Skip to content

Instantly share code, notes, and snippets.

@miwebguy
Created April 28, 2020 15:36
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miwebguy/417160798c8c1b275a0d15d04bf01954 to your computer and use it in GitHub Desktop.
Save miwebguy/417160798c8c1b275a0d15d04bf01954 to your computer and use it in GitHub Desktop.
TableFilter.js
/**
* Table Filter
* @usage: <input type="search" onkeyup="Tablefilter(this, 'VReportList')" />\
* where VReport is the id of the table body
*/
function Tablefilter (phrase, _id) {
var words = phrase.value.toLowerCase().split(" ");
var table = document.getElementById(_id);
var ele;
for (var r = 0; r < table.rows.length; r++ ) {
ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
var displayStyle = 'none';
for (var i = 0; i < words.length; i++) {
if (ele.toLowerCase().indexOf(words[i])>=0) { displayStyle = '';}
else { displayStyle = 'none'; break; }
}
table.rows[r].style.display = displayStyle;
}
}
function countDisplayedRows(_id)
{
var hiddenRowCount = 0;
var table = document.getElementById(_id);
var rows = table.getElementsByTagName("tr");
for (var i = 0; i < rows.length; i++) {
if(rows[i].style.display == 'none') hiddenRowCount++;
}
shown = rows.length - hiddenRowCount;
document.getElementById('DisplayCount').innerHTML = shown;
}
@PAT22082
Copy link

PAT22082 commented May 6, 2022

dfdgfg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment