title: JS error Uncaught ReferenceError: 'name' is not defined at HTMLAnchorElement.onclick
body: <p>I'm building a html string in my JS function and appending it to my div on an AJAX call but i get the above error, what I dont understand is why its throwing the error for one part and not the other.</p>
  <pre><code>html += &quot;&lt;td&gt;&quot; + employeeid + &quot;&lt;/td&gt;&lt;td onclick='getemployeesig(&quot; + signature + &quot;)'&gt;Show Signature&lt;/td&gt;...
  </code></pre>
  <p>this above works fine but below doesn't and throws the error. Names is a set.</p>
  <pre><code>names.forEach(function (value) {
                  let bs = value.replace(/\s+/g, '');
                  let cs = bs.replace('&quot;', '');
                  supervisorshtml += &quot;&lt;a href='#' onclick=supervisorFilter(&quot;+cs+&quot;)&gt;&quot; + value + &quot;&lt;/a&gt;&quot;;
              })
  </code></pre>
  <p>ive appended like this</p>
  <pre><code>    $(&quot;#trainingTable&quot;).append(html);
      $(&quot;#superVisorList&quot;).append(supervisorshtml);
  </code></pre>
  <p>my functions are</p>
  <pre><code>function supervisorFilter(supervisorId) {
      alert(&quot;Called&quot;);
  } 
  
  function getemployeesig(employeeid) {
      alert(&quot;Called&quot;);
  }
  </code></pre>
  <p>To note, the html I am trying to bind to is</p>
  <pre><code>&lt;div class=&quot;dropdown&quot;&gt;
              &lt;button class=&quot;dropbtn&quot;&gt;Select Supervisor&lt;/button&gt;
              &lt;div class=&quot;dropdown-content&quot; id=&quot;superVisorList&quot;&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  <p>And this is all created in</p>
  <pre><code>$(document).ready(function () { }
  </code></pre>