javascript - basic onclick event question
<p>I have a dynamic table populated from an array.</p>

<p>When building the table I have the following inside of a loop:</p>

<pre><code>var tdRecord = trRecord.insertCell(trRow.cells.length);
var tdRecordId = dataArray[j][0];
tdRecord.onclick = function() { alert(tdRecordId); }
</code></pre>

<p>The problem is that alert will only alert the last set tdRecordId in the array. If I click on any of the other td rows they all alert the same number.</p>

<p>Anyone know how I can fix this?</p>
