Jump to content

Elka74100

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Elka74100

  1. Hi Guys,

    I am using the CSS Javascript filter table which is posted on W3 website : https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_filters_table

    It works well but searches only in the first column of the table and I would like it searches in both.

    If someone could give me the solution I would really appreciate that. ;) 

    Thank you very much in advance.

    PS: The code

    function myFunction() {
      var input, filter, table, tr, td, i;
      input = document.getElementById("myInput");
      filter = input.value.toUpperCase();
      table = document.getElementById("myTable");
      tr = table.getElementsByTagName("tr");
      for (i = 0; i < tr.length; i++) {
        td = tr.getElementsByTagName("td")[0];
        if (td) {
          if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
            tr.style.display = "";
          } else {
            tr.style.display = "none";
          }
        }
      }
    }

     

×
×
  • Create New...