Add rows in existing HTML table having aspx drodown

Rajni.Shekhar
Posted by Rajni.Shekhar under JavaScript category on | Points: 40 | Views : 1235
in js file

function AddRows(TableName, headerCount, totRowCount)
{
for(var i=0;i<totRowCount;i++)
{
InsertTableRow(TableName,headerCount);
}
}

function InsertTableRow(TableName,headerCount)
{
var tblName=document.getElementById(TableName);
var iCols, iRows;
var tblRow;
var allRows=tblName.getElementsByTagName('tr');
var rowPos=tblName.rows.length-headerCount;
var newRow=allRows[rowPos].cloneNode(true);
var root = tblName.rows[rowPos].parentNode;
//get input controls
var rowINPUT=newRow.getElementsByTagName('input');
for(var i=0; i<rowINPUT.length;i++)
{
var ID=rowINPUT[i].getAttribute("id").split('_');
rowINPUT[i].setAttribute("id",ID[0]+'_'+rowPos);
}

//for asp.net drop down list
var cloneDDL = newRow.getElementsByTagName('select');
for(var j=0; j<cloneDDL.length;j++)
{
//alert(rowPos);
var ID=cloneDDL[j].getAttribute("id").split('_');
cloneDDL[j].setAttribute("id",ID[0] + '_' + ID[1] + '_' + ID[2] + '_' + rowPos); //ctl_contentplaceholder1_ddl_0
//alert(cloneDDL[j].getAttribute("id"));
}
root.appendChild(newRow);
}

Comments or Responses

Login to post response