/    Sign up×
Community /Pin to ProfileBookmark

Dynamic HTML Table Deletion.

Hey Gang.
I have created a new table like this:
the var tbl = pd.appendChild(document.createElement(‘table’));
var thead = tbl.appendChild(document.createElement(‘thead’));
var tbody = tbl.appendChild(document.createElement(‘tbody’));
Rows and cells were created also created as well using the insertRow and insertCell method. My question is, how would I delete the entire table? What is the syntax for it?
I hope someone out there can help me out.
A big thanks in advance.
Cheers
Dan.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@fredmvApr 14.2004 — First, get a reference to the table (this is one of several ways you can do it):var tableRef = document.getElementById('myTable');This of course assumes you have set the [font=courier]id[/font] attribute of the table to "myTable". Next, all you have to do is remove the child node from the tree:document.body.removeChild(tableRef);
Copy linkTweet thisAlerts:
@boy3696authorApr 14.2004 — Thanks very much Fredmv...

I was soooooo close.

Here's what I had just finished when I got your email.

if (tableID == "ParentCompanyBusinessUnitProfiles") {

pd = document.getElementById(tableID);

var tbl = pd.removeChild(tableID);

}

the only difference being that you had the word body.

Once again, thanks for your help buddy.

I apprecieate it very much.

Cheers

Dan.
Copy linkTweet thisAlerts:
@fredmvApr 14.2004 — You're quite welcome Dan; glad that helped you out. ?
Copy linkTweet thisAlerts:
@boy3696authorApr 14.2004 — Hi Everyone (Especially Fredmv)

Thanks for checking this post out, but I'm still having problems deleting a child. (Fredmv, you might see something that's just jumping off the page, where's I can't... I guess I've been looking at it to long.)

If anyone can see why I can't delete the Child in the attached file, I would appreciate some help. It's working code, so just create an HTML file from it.

Cheers,

Dan.

P.S. It's in the deleteRow function and clearly marked with comments where the issue lies. I also have alerts in there so if you run it, you'll see values I'm putting out.

I just can't figure this out.

Thanks again.

Cheers.

[upl-file uuid=12a25f65-bbf4-49e1-a97d-4c69c02a8165 size=21kB]postsample1.txt[/upl-file]
Copy linkTweet thisAlerts:
@boy3696authorApr 14.2004 — Everyone who looked at my issue, Thanks. I'm just posting this message to give everyone what I found (the solution).

After playing around with it, I forgot I had a nested tag, so I also had to include that tag in the removing of the child.

Attached is a working copy of the html that removes the child for anyone interested in the syntax of how I did this.

Feel free to use anypart of the code, and if there's a more efficient way of doing things in this html that I haven't done, please feel free to let me know. I beleive in sharing knowledge so nobody had to go through the same thing...

Cheers my friends.

Dan.

?

[upl-file uuid=28c72fa0-4aad-4683-8572-8f2f0f918ee1 size=20kB]postsample1.txt[/upl-file]
×

Success!

Help @boy3696 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...