removing a row from a table
- by Joe Jr Yamut
i’ve had trouble removing a row from a table using javascript. the tricks i’ve learned assumes that i am dealing with a div always. in some cases, i can’t help but use a table.
a quick google search offered me a lot of solutions. this is the one that worked in my case, and is just 2 lines! for convenience i just placed it in a function.
function removeTableRow(row,tableid)
{
var r=row.parentNode.parentNode.rowIndex;
document.getElementById(tableid).deleteRow(r);
}
so using the function above, you have the following line somewhere:
onclick=”removeTableRow(this,’myTable’)”;
and somewhere else you have a table that is defined like this:
<table id=’myTable’>
.. .
.. .
.. .
</table>
Similar Posts:
- > “zeroing in” hits page 1 December 2, 2007
- > Simple SQL Query Builder June 23, 2021
- > Getting the front panel audio jack working June 25, 2010
- > Novell Moonlight Is In A Lunar Eclipse September 24, 2011
- > Very Light Virtual CD ROM App For Windows September 21, 2009
i’ve had trouble removing a row from a table using javascript. the tricks i’ve learned assumes that i am dealing with a div always. in some cases, i can’t help but use a table. a quick google search offered me a lot of solutions. this is the one that worked in my case, and is…