title: Passing two variables to one JavaScript function
body: <p>I have completed if I pass a variable <code>id</code> but now I want to pass <code>name</code> to the same function when I click on a image. This is my code:</p>
  
  <pre><code> for (var i = 0; i &lt;friend_data.length; i++) {
                          results += '&lt;div class = "clicker" id = "'+friend_data[i].id+'" onclick="javascript:testId(this.id,'+ friend_data[i].name+')"&gt;&lt;img src="https://graph.facebook.com/' + friend_data[i].id + '/picture" height="30" width="30"&gt;' + friend_data[i].name + '&lt;/div&gt;';
                      }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>function testId(id, friend_data[id].name ){
      alert(id);
      alert(friend_data[i].name);     
  }
  </code></pre>
  
  <p>The <code>alert(friend_data[i].name);</code> does not show because it's wrong. Please help me to correct it.
  Please look in even <code>onclick</code> it's the right ways to pass variable?   </p>