Here's the bit of code that I took from the Table Search and Filter (http://cscstud.blogspot.com/2012/11/javascript-search-and-filter-table.html#more) post, that'll refresh the table. It may not be too pretty and it probably shows that I don't have the greatest understanding, but it works. Just add this bit inside the <script> tags you already have for the search & filter and create a button that refers back to it inside a div tag or table. Also if you haven't already, make sure to add the onload="tableSearch.init(); to your body tag.
tableSearch.refresh = function() {
//get the search term
this.Term == '';
//loop through the rows and hide rows that do not match the search query
for (var i = 0, row; row = this.Rows[i], rowText = this.RowsText[i]; i++) {
row.style.display = ((rowText.indexOf(this.Term) != -1) || this.Term === '') ? '' : '';
}
}
/* Here's the code for the button */
<input type="button" value="refresh" onclick="tableSearch.refresh();"/>
No comments:
Post a Comment