Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Feb 25, 2011 @ 06:49
    syn-rg
    0

    Checkbox list values replace comma with comma and space

    I have a checkbox list that when multiple values are selected the values display as:
    Project type: Fitout,Refurbishment
    http://isis.brandtoolbox.com.au/projects/projects/office/abc-radio-triple-j.aspx (check Project type:)

    I tried using umbraco.library:Replace to change the comma to a comma and space. (',' , ', ') or (',' , ',  ')

    But can't get it to work, can anyone help?

    Cheers,
    JV

  • Daniel Bardi 927 posts 2562 karma points
    Feb 25, 2011 @ 07:43
    Daniel Bardi
    0

    This should help you: http://our.umbraco.org/wiki/reference/umbracolibrary/split

    Do this:

    <xsl:variable name="selectedValues" select="umbraco.library:Split($commaSeperatedList,',')" />
    <xsl:for-each select="$selectedValues//value">
    <xsl:value-of select="current()" />
    <xsl:if test="position() != last()">,&nbsp;</xsl:if>
    </xsl:for-each>
  • Kim Andersen 1447 posts 2197 karma points MVP
    Feb 25, 2011 @ 08:45
    Kim Andersen
    0

    Hi JV

    You should actually be able to do this with the Replace-extension. Try this:

    <xsl:variable name="comma"><![CDATA[,]]></xsl:variable>
    <xsl:variable name="commaSpace"><![CDATA[, ]]></xsl:variable>
    <xsl:value-of select="umbraco.library:Replace($currentPage/aliasOfCheckbox,$comma,$commaSpace)" />

    /Kim A

  • Kim Andersen 1447 posts 2197 karma points MVP
    Feb 25, 2011 @ 08:49
    Kim Andersen
    3

    Ohh, actually when I think about it, shouldn't this work as well:

    <xsl:variable name="values" select="concat($currentPage/aliasOfCheckbox,',')"/>
    <xsl:value-of
    select="umbraco.library:Replace($values, ',', ', ')" />

    In my first example, you might need to use the concat method also.

    /Kim A

  • Daniel Bardi 927 posts 2562 karma points
    Feb 25, 2011 @ 08:49
    Daniel Bardi
    0

    Both work.. I like Kim's.. it's easier for the task

  • syn-rg 282 posts 425 karma points
    Feb 25, 2011 @ 23:32
    syn-rg
    0

    Thanks Kim and Daniel!

    I went with Kim's solution, and it's working perfectly.
    Cheers!

  • Kim Andersen 1447 posts 2197 karma points MVP
    Feb 26, 2011 @ 09:02
    Kim Andersen
    0

    You are welcome JV. Great to hear that you got the problem solved!

    /Kim A

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies