Dynamically delete row using javascript

Posted by Senthilmcatyr under ASP.NET on 1/5/2012 | Points: 10 | Views : 1004 | Status : [Member] | Replies : 0
Hi,
I used dynamically add row and delete row using javascript in asp.net. Insert value via add row function. I delete row function only delete the row but doesnot delete the data. how can i delete the data when delete the row? pls help me.

Here is my code,
***********************
function addRowToTable1(){
var tbody = document.getElementById('tblFilter').getElementsByTagName('tbody')[0];
var newtr = document.createElement('tr');
var newtd = document.createElement('td');
var tbl = document.getElementById('tblFilter');
var lastRow = tbl.rows.length;
var iteration = lastRow;
document.getElementById('HiddenField1').value=lastRow;
newtd.innerHTML = iteration;
newtr.appendChild(newtd);


newtd = document.createElement('td');
var fieldName = 'tbl1txtRow' +iteration;
newtd.innerHTML = '<input type=text name=' + fieldName + ' id=' + fieldName + ' size=40 value=\'\'>';
newtr.appendChild(newtd);

newtd = document.createElement('td');
var fieldName = 'hd' +iteration;
newtd.innerHTML = '<input type=hidden name=' + fieldName + ' id=' + fieldName + ' size=42 value=\'\'>';
newtr.appendChild(newtd);

newtd = document.createElement('td');
fieldName = 'tbl1radio1Row' +iteration;
newtd.innerHTML = '<input type=radio name=' + fieldName + ' id=' + fieldName + ' value=existed>&nbsp;&nbsp;Existing field&nbsp;&nbsp;<input type=radio name=' + fieldName + ' id=' + fieldName + ' value=new checked="checked">&nbsp;&nbsp;New field';
newtr.appendChild(newtd);

newtd = document.createElement('td');
fieldName = 'tbl1radio2Row' +iteration;
newtd.innerHTML = '<input type=radio name=' + fieldName + ' id=' + fieldName + ' value=popupYes>&nbsp;&nbsp;Yes&nbsp;&nbsp;<input type=radio name=' + fieldName + ' id=' + fieldName + ' value=popupNo checked="checked">&nbsp;&nbsp;No&nbsp;&nbsp;';
newtr.appendChild(newtd);

newtd = document.createElement('td');
fieldName = 'tbl1radio3Row' +iteration;
newtd.innerHTML = '<input type=radio name=' + fieldName + ' id=' + fieldName + ' value=drilldownYes>&nbsp;&nbsp;Yes&nbsp;&nbsp;';
newtr.appendChild(newtd);

newtd = document.createElement('td');
newtd.innerHTML = '<input type=radio name=' + fieldName + ' id=' + fieldName + ' value=drillacrossYes checked="checked">&nbsp;&nbsp;Yes&nbsp;&nbsp;';
newtr.appendChild(newtd);

newtd = document.createElement ('td');
fieldName = 'btnDel' +iteration;
newtd.innerHTML = '<input type=button name=' + fieldName + ' id=' + fieldName + ' value=Delete onclick="deleteRow(this)">';
newtr.appendChild(newtd);

tbody.appendChild(newtr);
}




Responses

(No response found.)

Login to post response