[JS - Snippet] Filter table
1 post
Page 1 of 1
Hello,
This code snippet is going to filter table (read: hide rows which don't match the text). Just attach event to some element and call function
This code snippet is going to filter table (read: hide rows which don't match the text). Just attach event to some element and call function
Code: Select all
function filter (phrase, _id){
var words = phrase.value.toLowerCase().split(",");
var table = document.getElementById(_id);
var ele;
for (var r = 1; 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;
}
}
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023