How to pass a JavaScript variable in onClick function
<p>Here is my code, I wanna get the element info in the click function like my annotation says.</p>

<pre><code>for(var i = 0, len = json.length; i &lt; length; i++) {
  var curid = json['success'][i]['courier_id'];
  var curname = json['success'][i]['courier_name'];
  document.getElementById("gsid").value=curname;                    
  var tr="&lt;tr&gt;&amp;nbsp;&amp;nbsp;";

  //here is where i want to use onclick function with curid and curname 
  var td1="&lt;td&gt;"+"&lt;input type='radio' name='as' value='json['success'][i]['courier_id']' id='curiid' onclick='courierselect(&lt;?php echo $shyam='\'+curname+\''; ?&gt;);'/&gt;"+"&lt;/td&gt;&amp;nbsp;&amp;nbsp;";
  var td2="&lt;td id='curnname'&gt;"+json['success'][i]['courier_name']+"&lt;/td&gt;&amp;nbsp;&amp;nbsp;";
  var td3="&lt;td&gt;"+json['success'][i]['country_charge']+"&lt;/td&gt;&amp;nbsp;&amp;nbsp;";
  var td4="&lt;td&gt;"+json['success'][i]['estimate_delivery_time']+"&lt;/td&gt;&amp;nbsp;&amp;nbsp;";
  var td5="&lt;td&gt;"+json['success'][i]['tracking_available']+"&lt;/td&gt;&lt;/tr&gt;&amp;nbsp;&amp;nbsp;";
  $("#results").append(tr+td1+td2+td3+td4+td5); 
}
</code></pre>