title: JavaScript - For loop button onclick
body: <p>I've a javascript that goes through for loop, make table in HTML page and then calls specific function to update specific values for that user. </p>
  
  <pre><code>function getUsers() {
    //get all users as "parsedJSON" array
    for (var i=0; i&lt;countrows; i++ ) {
      row.insertCell(0).innerHTML = parsedJSON[i].samaccountname;
      row.insertCell(1).innerHTML = parsedJSON[i].givenname;
      row.insertCell(2).innerHTML = parsedJSON[i].surname;
      var userName = parsedJSON[i].samaccountname;
      row.insertCell(3).innerHTML = "&lt;button id='userName' onclick = 'updateUser(this.id)'&gt; ActionUser&lt;/button&gt;";
    }
  }
  
  function updateUser(userName) {
      //Function with about 30 lines to update user
  }
  </code></pre>
  
  <p>Now, my question is: How can I know, which specific user's button was clicked and how can I pass its username to updateUser function?</p>
  
  <p>Thanks in Advance </p>