Thursday, May 19, 2005

DOM

To View the DOM
---------------------------------------------------

var node = xmlDom.selectSingleNode("//HeaderTable");
for(var i=0; i < node.length ;i++ )
{
alert(node[m].xml);
alert(node[m].getAttribute("UserName"));
}


Dynamically Add the Row in the Tabel using DHTML
---------------------------------------------------
function addnew(tablename)
{
var table = get(tablename);
var objrow = table.insertRow(table.rows.length);
for(var i = 0; i < table.rows[0].cells.length; i++)
{

var cell = objrow.insertCell(i);
cell.className = table.rows[1].className;
cell.innerHTML = table.rows[1].cells[i].innerHTML;
cell.value="";


if(cell.parentNode.rowIndex!=1)
{
table.rows[cell.parentNode.rowIndex].cells[0].innerHTML=cell.parentNode.rowIndex;
}
}
}

Dynamically Delete the Row in the Tabel using DHTML
---------------------------------------------------



function deleterow(obj,tablename)
{

var table = get(tablename);
if(obj.parentElement.parentElement.rowIndex > 1 )
{
table.deleteRow(obj.parentElement.parentElement.rowIndex);

for(var i = 0; i < table.rows.length; i++) //Reshuffle the Serial Number
{
if(i!=0)
{
table.rows[i].cells[0].innerHTML = i;
}
}
}
else
{
alert("This row Cannot be deleted");
}

}

No comments: