/    Sign up×
Community /Pin to ProfileBookmark

delete a line ina table?

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

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@AdamBrillAug 07.2003 — Yes, it is possible. Take a look at this:&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function delete_tr(event){
if(event.srcElement.tagName=="TD"){
event.srcElement.parentElement.parentElement.deleteRow(event.srcElement.parentElement.rowIndex);
}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onclick="delete_tr(event);"&gt;
&lt;table border=1&gt;
&lt;tr&gt;
&lt;td&gt;
test
&lt;/td&gt;
&lt;td&gt;
test
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
test1
&lt;/td&gt;
&lt;td&gt;
test1
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
test2
&lt;/td&gt;
&lt;td&gt;
test2
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
test3
&lt;/td&gt;
&lt;td&gt;
test3
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
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. ?
Copy linkTweet thisAlerts:
@pyroAug 07.2003 — Try this (IE only...):

&lt;script type="text/javascript"&gt;
function removeCell() {
document.getElementById("celltwo").removeNode(true);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td id="cellone"&gt;One&lt;/td&gt;
&lt;td id="celltwo"&gt;Two&lt;/td&gt;
&lt;td id="cellthree"&gt;Three&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;a href="#" onclick="removeCell(); return false;"&gt;Remove&lt;/a&gt;&lt;/p&gt;
Copy linkTweet thisAlerts:
@pelegk1authorAug 07.2003 — thats execlly what i wanted
×

Success!

Help @pelegk1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...