Dynamically delete rows in javascript

Posted by Senthilmcatyr under JavaScript on 2/10/2012 | Points: 10 | Views : 2490 | Status : [Member] | Replies : 3
I used dynamic add and delete row in asp.net using javascript. Add row functionality ok. Delete row functions manually worked but functionality wise is not ok. how to possible delete rows in javascript?

My delete row codings:
function removeRowFromTable()
{
var tbl = document.getElementById('tblFilter');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}

if anybody knows pls help me.




Responses

Posted by: Sksamantaray on: 2/11/2012 [Member] Silver | Points: 25
Posted by: Abhisekjani on: 2/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
refer to following links
http://www.dotnetfunda.com/forums/thread7344-dynamically-delete-row-using-javascript.aspx
http://viralpatel.net/blogs/2009/03/dynamically-add-remove-rows-in-html-table-using-javascript.html
http://psoug.org/snippet/Javascript-Dynamically-AddRemove-rows-in-HTML-table_894.htm

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Senthilmcatyr,
I think, your code is fine,

you can also delete like following code

var table = tblName;
var node = from;
while (node != null)
{
if (node.tagName == "TR")
{
input_box=confirm("Do you want to delete?");
if (input_box==true)
{
rIndex = node.rowIndex;
table.deleteRow(rIndex);
}
else
{ return false; }
}
}




Thanks,
Rajni Shekhar

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response