Removing a column from a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeredDrahcir
    Contributor
    • Nov 2009
    • 426

    Removing a column from a table

    I have a table. I can't change the structure but I need to remove a column from it. I used the nth-child() pseudo-class to set the display of the column to none but there are three rows at the bottom and they have a colspan set so now I'm getting a gap on the upper rows where the column is missing.

    Is it possible to adjust the table in anyway, I'm prepared to use JavaScript to change the table so that they colspan is reduced?

    What are the options?
    Code:
    <table width="100%" border="0" cellpadding="2" cellspacing="1" id="[I]id[/I]">
      <tr>
        <td>[I]content[/I]</td>
        <td>[I]content[/I]</td>
        <td>[I]content[/I]</td>
        <td>[I]content[/I]</td>     
        <td>[I]content[/I]</td>
        <td>[I]content[/I]</td>
      </tr>
      <tr>
        <td align="center">
          [I]content[/I]
        </td>
        <td>[I]content[/I]</td>
        <td>
          <table  border="0" align="left">
            <tr>
              <td align="left">[I]content[/I]</td>
              <td>[I]content[/I]</td>
              <td align="right">[I]content[/I]</td>
            </tr>
          </table>
        </td>
        <td align="center">[I]content[/I]</td>
        <td align="right">[I]content[/I]</td>
        <td align="right">[I]content[/I]</td>
      </tr>
      <tr>
        <td colspan="5" align="right">[I]content[/I]</td>
        <td align="right">[I]content[/I]</td>
      </tr>
      <tr>
        <td colspan="5" align="right">[I]content[/I]</td>
        <td align="right">[I]content[/I]</td>
      </tr>
      <tr>
        <td colspan="5" align="right">[I]content[/I]</td>
        <td align="right">[I]content[/I]</td>
      </tr>   
      <tr>
        <td colspan="5" align="right">[I]content[/I]</td>
        <td align="right">[I]content[/I]</td>
      </tr>
    </table>
    It's the fifth column I'd like to hide.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    There's no way to do it in just CSS if you're not allowed to change the HTML. However, if you're allowed to, use JavaScript to change the structure of the table.

    Comment

    • KeredDrahcir
      Contributor
      • Nov 2009
      • 426

      #3
      I'm prepared to use JavaScript but can't find the code to do it. Are you able to help me there?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Well, in all honesty, if you don't know javascript, it would be a lot easier if you asked them to allow you to edit the HTML table rather than working around it through javascript. Because javascript can be disabled by the user and then the table would be wrong anyways.

        Comment

        Working...