Copied to clipboard

Flag this post as spam?

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


  • Max 144 posts 166 karma points
    Mar 30, 2011 @ 12:51
    Max
    0

    assign a selected Value in xslt from xsl vriable

    <xsl:variable name="Year" select="umbraco.library:RequestQueryString('Year')"/>
    I can get this paramter now i wantto assign the value in dropdownlist if there is value or else  wil not assign The selected value in XSLT file

     <select name="mylist" id="DropNewsYear" OnChange="location='{umbraco.library:NiceUrl($currentPage/@id)}?Year='+getSelect(this)" >

     <option selected="selected" value="ChooseYear">Choose Year</option>
             <option value="2011">2011</option>
     <option value="2010">2010</option>
     <option value="2009">2009</option>
     <option value="2008">2008</option>
     <option value="2007">2007</option>
     <option value="2006">2006</option>
     <option value="2004">2005</option>
     <option value="2004">2004</option>
     
    </select>  
     

    any Code example wil be useful

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 30, 2011 @ 13:24
    Kim Andersen
    0

    If I understand you correct something like this should work:

    <option value="{$Year}"><xsl:value-of select="$Year" /></option>

    /Kim A

  • rorythecheese 110 posts 56 karma points
    Mar 30, 2011 @ 17:24
    rorythecheese
    0

    If you mean to mark the year in the querystring as the selected value in the dropdown then you can do this.

    <xsl:variable name="Year" select="umbraco.library:RequestQueryString('Year')"/>
    <xsl:for-each select="/list/of/years">
      <option value="{.}">
          <xsl:if test=". = $Year">
              <xsl:attribute name="selected">selected</xsl:attribute>
          </xsl:if>
          <xsl:value-of select=".">
      </option>
    </xsl:for-each>
  • Sumit 1 post 21 karma points
    Apr 20, 2015 @ 16:49
    Sumit
    0

    <OPTION>

    <xsl:if test="$value = ./@value">

                       <xsl:attribute name="selected">selected</xsl:attribute>

                   </xsl:if>

                   <xsl:attribute name="value"><xsl:value-of select="./@value" /></xsl:attribute>

                   <xsl:value-of select="." />

                                    </OPTION>

    e.g. <option value=1>One</option>

Please Sign in or register to post replies

Write your reply to:

Draft