PDA

View Full Version : setting id to table cell....



bphein1980
Aug 25th, 2005, 04:36 PM
Hopefully this is simple for all you experts. Of course I am another newbie trying to learn the ways...

This is part of the code found on mredkj.com, edited to my liking. What I am trying to do is set an ID to each table cell that is created.



function addRowToTable(val)
{
var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.rows.length;
var iteration = nextRow - parseInt(headerRows) + parseInt(1);

// add the row
var row = tbl.insertRow(nextRow);

// CONFIG: This whole section can be configured

// cell 0 - text
var cell0 = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cell0.appendChild(textNode);

// cell 1 - input text
var cell1 = row.insertCell(1);
var txtInp1 = document.createElement('input');
txtInp1.setAttribute('type', 'text');
txtInp1.setAttribute('size', '1');
txtInp1.onkeyup = function () {calTime(this)};
cell1.appendChild(txtInp1);

var txtInp2 = document.createElement('input');
txtInp2.setAttribute('type', 'text');
txtInp2.setAttribute('size', '1');
txtInp2.onkeyup = function () {calTime(this)};
cell1.appendChild(txtInp2);

var txtInp3 = document.createElement('input');
txtInp3.setAttribute('type', 'text');
txtInp3.setAttribute('size', '1');
txtInp3.onkeyup = function () {calTime(this)};
cell1.appendChild(txtInp3);

var txtInp4 = document.createElement('input');
txtInp4.setAttribute('type', 'text');
txtInp4.setAttribute('size', '1');
txtInp4.onkeyup = function () {calTime(this)};
cell1.appendChild(txtInp4);

var txtInp5 = document.createElement('input');
txtInp5.setAttribute('type', 'text');
txtInp5.setAttribute('size', '1');
cell1.appendChild(txtInp5);

// Pass in the elements you want to reference later
// Store the myRow object in each row
row.myRow = new myRowObject(textNode, txtInp, cbEl);
}

Thanks in advance.

SpirtOfGrandeur
Aug 25th, 2005, 04:59 PM
Hopefully this is simple for all you experts. Of course I am another newbie trying to learn the ways...

This is part of the code found on mredkj.com, edited to my liking. What I am trying to do is set an ID to each table cell that is created.

Thanks in advance.


cell1.id = 'this_is_my_id'

Make sure the id's are unique.