/    Sign up×
Community /Pin to ProfileBookmark

Remove/modify certain th and td

This is kind of beyond my javascript/DOM knowledge and could use a help on this topic.

I’m using a third party software to populate a table (id=roster) contents that resides in a specified page that I need a script to work only for (other page use this table too but don’t need script to do it):

basic table structure come out something like this:

[CODE]
<body id=”pagebody”>
<table id=”roster”>

<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
continue to populate tds depend on how many fields are stored in db
<tr>
<th colspan=”7″></th>
</tr>
<tr>
<th colspan=”3″></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<th colspan=”3″></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<th colspan=”3″></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<th colspan=”7″></th>
</tr>

</table>
</body>
[/CODE]

Okay, now it comes to figure how the script should be written based on the process below:

  • 1.

    detect and remove (use removeChild) each last two of th and td from each tr that has seven th/td

  • 2.

    modify tr’s attribute rowspan=7 to rowspan=5 due to the removal of ths and tds

  • 3.

    remove each last two of th and td in each tr that has 5 th (one of them use rowspan=3).

  • Hope it explains clearly and appreciate any help in advance!

    johnny

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @johnny41 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 6.16,
    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: @nearjob,
    tipped: article
    amount: 1000 SATS,

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

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