Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Unhappy JavaScript XSLT getElementByID with multiple same ID's

    Hi,

    I have a problem when trying to hide some <td> cells using javascipt.

    The problem I have is that my table is being produced by XSLT using <xsl:apply-templates select="Data/DataRow" /> to create the rows. This means that all of the rows have the same ID and therefore I cannot use getElementByID.

    e.g.

    Code:
                    <table>
                      <tr>
                        <td>
    		Client Name
                        </td>
                      </tr>
                      <xsl:apply-templates select="Data/DataRow" />
    I also do not want to hide all the <td> only certain columns with certain id's.

    I have tried the below with no luck.

    Code:
    cells2 = table.getElementsByTagName('td').getElementById('colid');
    Please help I am tearing my hair out here!!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    Well, your template is faulty, because of course multiple occurrences of the same ID are illegal HTML.

    So perhaps you need to just use relative row and cell numbers?

    That is:
    Code:
    var cellX = table.rows[7].cells[3];
    or similar?

    Would help if you showed the template.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •