[thelist] adding an event to a DOM dynamically added row
Tom Dell'Aringa
pixelmech at yahoo.com
Fri Mar 14 11:56:37 CST 2003
Hi all,
I am adding rows to a table with the DOM. They now want to add an
onclick event as well. They were trying setAttribute() with no
success. Anyone know how we could accomplish this? Here is a snippet
of how we are doing it:
var rowNum = 3;
function addPerfRow(bodyName, tableName)
{
docBody = document.getElementById(bodyName);
tableName = document.getElementById(tableName);
newRow = document.createElement("TR");
newRow.className = "GridItem";
for (i = 0; i < 7; i++)
{
cell = document.createElement("TD");
field = document.createElement("INPUT");
switch(i) // have like 7 cells
{
// we want an onclick on this button for
example
case 0:
field.type = "button";
field.id = "delPerf_" + rowNum;
field.name = "delPerf_" + rowNum;
break;
case 1:
field.type = "text";
field.size = "20";
field.maxLength = "25";
field.id = "perfType_" + rowNum;
field.name = "perfType_" + rowNum;
break;
}
cell.appendChild(field)
newRow.appendChild(cell)
}
rowNum += 1;
docBody.appendChild(newRow)
}
TIA
Tom
=====
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http://www.pixelmech.com/
var me = tom.pixelmech.webDeveloper();
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
More information about the thelist
mailing list