Click to See Complete Forum and Search --> : delete a line ina table?


pelegk1
08-07-2003, 07:12 AM
i have a <div>
to which i d/l a table!
each <tr> in the table recives an id!
is there a way to delete a line from the table?
if yes then how???
thanks in advance
peleg

AdamBrill
08-07-2003, 07:36 AM
Yes, it is possible. Take a look at this:<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function delete_tr(event){
if(event.srcElement.tagName=="TD"){
event.srcElement.parentElement.parentElement.deleteRow(event.srcElement.parentElement.rowIndex);
}
}
</script>
</head>
<body onclick="delete_tr(event);">
<table border=1>
<tr>
<td>
test
</td>
<td>
test
</td>
</tr>
<tr>
<td>
test1
</td>
<td>
test1
</td>
</tr>
<tr>
<td>
test2
</td>
<td>
test2
</td>
</tr>
<tr>
<td>
test3
</td>
<td>
test3
</td>
</tr>
</table>
</body>
</html>When you click on a row, it will get deleted... If you need it modified and can't figure out how to do it, let me know what you want changed and I'd be happy to help. ;)

pyro
08-07-2003, 07:39 AM
Try this (IE only...):

<script type="text/javascript">
function removeCell() {
document.getElementById("celltwo").removeNode(true);
}
</script>
</head>
<body>
<table>
<tr>
<td id="cellone">One</td>
<td id="celltwo">Two</td>
<td id="cellthree">Three</td>
</tr>
</table>
<p><a href="#" onclick="removeCell(); return false;">Remove</a></p>

pelegk1
08-07-2003, 09:45 AM
thats execlly what i wanted