i create an table with createElement. The table, tr and td get an id. Every td gets an dblclick eventlistener. So when you do an dblick a div will be shown.
but i get back the wrong id. I get only the id of the last entry.
I check the entry in the debugg mode,it's ok, why i get only the last id?
i want to get the id of the element, when i do a dblclick.
Insert Function:
countTable ++;
document.getElementById("counterTable").value = countTable;
var range= sel.getRangeAt(0);
myParent=document.getElementById("iframe_editor").contentWindow.document.body;
table=document.createElement("TABLE");
table.id = "tableid"+countTable;
for (i = 1; i <= document.getElementById("numoftr").value; i++)
{
tr = document.createElement("TR");
tr.id = table.id+"-"+"trid"+i;
for (j = 1; j<= document.getElementById("numoftd").value; j++)
{
td = document.createElement("TD");
td.id = tr.id+"-"+"tdid"+j;
td.addEventListener( 'dblclick', function(){
loadTableAttribute(td.id);
},td.id);
tr.appendChild(td);
}
table.appendChild(tr);
}
table.appendChild(emptyNode);
myParent.appendChild(table);
range.insertNode(table);
LoadTableAttribute
function loadTableAttribute(tdid)
{
alert(tdid);
}