This one is driving me nuts....
var tbl = document.create Element("table" );
var tbody = document.create Element("tbody" );
for(var i=0; i<10; i++) {
var row = document.create Element("tr");
var curVAR = someCurrentValu eOfArray[i];
row.addEventLis tener('click', function(e) {
alert(curVAR);
}, false);
var cell = document.create Element("td");
var cellText = document.create TextNode(i);
cell.appendChil d(cellText); row.appendChild (cell);
tbody.appendChi ld(row);
}
tbl.appendChild (tbody);
document.getEle mentById('tdiv' ).appendChild(t bl);
====
Now... Why isn't the curVAR 'assigned' to the row-alert-function???.
if I click one of the rows, only the last curVAR (10) is alerted, but the
i-variable is nicely showed 0 to 9 in the row....
Anyone???
Thanx in advance...
var tbl = document.create Element("table" );
var tbody = document.create Element("tbody" );
for(var i=0; i<10; i++) {
var row = document.create Element("tr");
var curVAR = someCurrentValu eOfArray[i];
row.addEventLis tener('click', function(e) {
alert(curVAR);
}, false);
var cell = document.create Element("td");
var cellText = document.create TextNode(i);
cell.appendChil d(cellText); row.appendChild (cell);
tbody.appendChi ld(row);
}
tbl.appendChild (tbody);
document.getEle mentById('tdiv' ).appendChild(t bl);
====
Now... Why isn't the curVAR 'assigned' to the row-alert-function???.
if I click one of the rows, only the last curVAR (10) is alerted, but the
i-variable is nicely showed 0 to 9 in the row....
Anyone???
Thanx in advance...
Comment