vinnu

vinnu

  • NA
  • 61
  • 202k

Please modify the java script for filtering the html table

May 11 2012 3:22 AM

HI,


i have the the javascript for filter but it will delete's the remaining rows
i dont want to delete the remaining code 
 function filter(term, _id, cellNr) {
            var suche = term.value.toLowerCase();
            var table = document.getElementById(_id);
            var ele;
            for (var r = 1; r < table.rows.length; r++) {
                ele = table.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g, "");
                if (ele.toLowerCase().indexOf(suche) >= 0) {
                    table.rows[r].style.display = '';                  
                }
                else {
                    table.rows[r].style.display = 'none';
                }
        }


Please modify the java script for filtering the html table

For ex: My table 

Column 1     column2     A            vini     B           Kiru     c           vini     D             Loki


if my key word is vini
 
then result should be in this way (i.e first rows should be the key word and followed by other words)

Column 1     column2     A            vini     c            vini     B            kiru     D              Loki 


or please suggest me any other solution for this problem


Answers (1)