Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alexey Shevchenko 15 posts 34 karma points
    Aug 30, 2011 @ 17:48
    Alexey Shevchenko
    0

    Unique id for all elements

    Hi all

    Could you help me? I need uniqu id for each <td>.

    I have a variable:
    <xsl:variable name="iterator" select="0"/>

    I want to increase a value of iterator in cycle. And as result id of <td> should be for example:

    "td_id_0", "td_id_1", "td_id_2", etc.

    As I've understood I should use concat(). But I don't understand how to increase value of iterator in cycle and how to put result of concatenation.

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">

        <td id="">

        </td>

    </xsl:for-each>

  • Rich Green 2246 posts 4008 karma points
    Aug 30, 2011 @ 17:52
    Rich Green
    0

    Hey,

    You can do something like this:

    <td>
    <xsl:attribute name="id">td_id_<xsl:value-of select="position()"/></xsl:attribute>
     </td>

    Rich

  • Alexey Shevchenko 15 posts 34 karma points
    Aug 30, 2011 @ 18:17
    Alexey Shevchenko
    0

    Thank You, Rich.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Aug 30, 2011 @ 18:47
    Chriztian Steinmeier
    1

    Hi Alexey,

    There's a convenient shortcut to that, using curly brackets (they're called an "Attribute Value Template"):

    <td id="td_id_{position()}"> ... </td>

    /Chriztian

  • Alexey Shevchenko 15 posts 34 karma points
    Aug 31, 2011 @ 11:23
    Alexey Shevchenko
    0

    Thank you, Chriztian!

Please Sign in or register to post replies

Write your reply to:

Draft