Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

Dom setAttribute ondblclick & ID for Table row/cell

Hi,

How do I add an onDblClick event for each table TR being created & how do I add an ID for each Cell being created.

function addRow(val1,val2)
{
tabBody = document.getElementsByTagName("TBODY").item(3);
row = document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
textnode1 = document.createTextNode(val1);
textnode2 = document.createTextNode(val2);
cell1.appendChild(textnode2);
cell2.appendChild(textnode1);
row.appendChild(cell1);
row.appendChild(cell2);
tabBody.appendChild(row);
}

0
kingasa
Asked:
kingasa
  • 3
1 Solution
 
a.marshCommented:
row.onclick = function { /* code here */ }

row.id = "id_here";


:o)

Ant
0
 
a.marshCommented:
Sorry, make that:

row.onclick = function() { /* code here */ }


Ant
0
 
a.marshCommented:
Let's get this right!

row.ondblclick = function() { /* code here */ }

and

cell1.id = ""id_here";

etc.

Ant
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now