title: Getting function not defined on keyup of input element
body: <p>Given the following table (a slightly modified version of this one at <a href="https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_filter_table" rel="nofollow noreferrer">w3schools</a>) but searches all columns, I'm getting the error that <code>searchAttorneys is not defined at HTMLInputElement.onkeyup</code> when entering a value in the textbox. Also, how can I keep the table headers from disappearing when searching the table?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;input type="text" id="search-attorneys" onkeyup="searchAttorneys()" placeholder="Search for names.." title="Type in a name"&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>function searchAttorneys() {
    var input, filter, table, tr, td, i;
    input = document.getElementById("search-attorneys");
    filter = input.value.toUpperCase();
    table = document.getElementById("attorneys");
    tr = table.getElementsByTagName("tr");
    for (i = 0; i &lt; tr.length; i++) {
      tds = tr[i].getElementsByTagName("td");
      var found = false;
      for (j = 0; j &lt; tds.length; j++) {
        td = tds[j];
        if (td) {
          if (td.innerHTML.toUpperCase().indexOf(filter) &gt; -1) {
            found = true;
            break;
          }
        }
      }
      if (found) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
  </code></pre>
  
  <p><strong>JSFIDDLE: <a href="https://jsfiddle.net/1zg85s9s/1/" rel="nofollow noreferrer">LINK</a></strong></p>