Copied to clipboard

Flag this post as spam?

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


  • shahnawaz 10 posts 30 karma points
    Apr 13, 2011 @ 10:00
    shahnawaz
    0

    How to Get Selected Value of DropDown

    Dear All

     

    I have following code. Please guide me how to get selected value of DropDown List.

    <select name="Month" id="Month" >
        <option value="0">Please Choose</option>
        <xsl:call-template name="for.loop">
         <xsl:with-param name="i">1</xsl:with-param>
         <xsl:with-param name="count">12</xsl:with-param>
        </xsl:call-template>
        </select>

    <option value="0">Please Choose</option>
          <xsl:if test="count($items) &gt; 0">
              <xsl:for-each select="$items/DateFolder">
                  <xsl:sort select="@nodeName" order="descending" />
                            <option value="{@nodeName}" >
                            <xsl:value-of select="@nodeName" />
                            </option>
                  </xsl:for-each>
          </xsl:if>
      </select>

    Please help. 

    Regards

    Muhammad Shahnawaz

    skype: muhammadshahnawaz

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 10:04
    Dirk De Grave
    0

    Do you need to get the selected value in xslt? If so, use

    <xsl:value-of select="umbraco.library:RequestForm('Month')" />

    where 'Month' is the id of the select html control

    Cheers,

    /Dirk

     

     

  • shahnawaz 10 posts 30 karma points
    Apr 13, 2011 @ 10:40
    shahnawaz
    0

    @Dirk

    <xsl:value-of select="umbraco.library:RequestForm('Month')" />

    dont return me anything. :(

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 10:42
    Dirk De Grave
    0

    Do you have a form on your template?

     

    Cheers,

    /Dirk

  • shahnawaz 10 posts 30 karma points
    Apr 13, 2011 @ 10:44
    shahnawaz
    0

    Following is my Whole Code

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:math="http://exslt.org/math"
    xmlns:umbraco.library="urn:umbraco.library"
    xmlns:yourprefix="urn:my-scripts"
    exclude-result-prefixes="msxml yourprefix umbraco.library">


    <xsl:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <msxsl:script implements-prefix='yourprefix' language='CSharp'>
    <![CDATA[
    public string monthName(int monthNum)
    {
    DateTime date = new DateTime(1,monthNum,1);
    return date.ToString("MMMM");
    }
    ]]>

    </msxsl:script>


        <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@level &gt; $minLevel and string(umbracoNaviHide) != '1'] "/>

    <xsl:variable name="minLevel" select="1"/>
    <xsl:template match="/">
        
      <div>
     <div style="float:left; width: 50px;">
      Year:
     </div>   
     <div style="float:left; width: 100px;">
     <select name="year" id="year" >
        <option value="0">Please Choose</option>
          <xsl:if test="count($items) &gt; 0">
              <xsl:for-each select="$items/DateFolder">
                  <xsl:sort select="@nodeName" order="descending" />
                            <option value="{@nodeName}" >
                            <xsl:value-of select="@nodeName" />
                            </option>
                  </xsl:for-each>
          </xsl:if>
      </select>
      </div>
      <div style="float:left; width: 50px;">
      &nbsp;
      </div>
       <div style="float:left; width: 50px;">
       Month:
      </div>
      <div style="float:left;width:100px;">
        <select name="Month" id="Month" >
        <option value="0">Please Choose</option>
        <xsl:call-template name="for.loop">
         <xsl:with-param name="i">1</xsl:with-param>
         <xsl:with-param name="count">12</xsl:with-param>
        </xsl:call-template>
        </select>
      </div>
        <div style="float:left; width: 50px;">
      &nbsp;
      </div>
        <xsl:variable name="monthNumber" select="umbraco.library:RequestForm('Month')" />
        <xsl:value-of select="$monthNumber" />
        <div style="float:left;width:100px;">
          <a href="?page={number($monthNumber)}">Show</a>
        </div>
      </div>
      <br/>
    </xsl:template>
     <xsl:template name="for.loop">
       <xsl:param name="i"/>
       <xsl:param name="count"  />
       <xsl:if test="$i &lt;= $count">
         <option value="{$i}" >
        <xsl:value-of select="yourprefix:monthName(number($i))"/></option>
         </xsl:if>
       <xsl:if test="$i &lt;= $count">
          <xsl:call-template name="for.loop">
              <xsl:with-param name="i">
                  <xsl:value-of select="$i + 1"/>
              </xsl:with-param>
              <xsl:with-param name="count">
                  <xsl:value-of select="$count"/>
              </xsl:with-param>
          </xsl:call-template>
       </xsl:if>
      </xsl:template>
     
      
    </xsl:stylesheet>

     

    I am using Form Tag in Content Page where i am using my all modules, macros and content

  • shahnawaz 10 posts 30 karma points
    Apr 13, 2011 @ 13:08
    shahnawaz
    0

    Any Help Guys?

  • shahnawaz 10 posts 30 karma points
    Apr 14, 2011 @ 09:57
    shahnawaz
    0

    Is it possible to get selected value of HTML Dropdown from XSLT? I cant find any help online. It has been more than a week

  • shahnawaz 10 posts 30 karma points
    Apr 14, 2011 @ 09:57
    shahnawaz
    0

    Is it possible to get selected value of HTML Dropdown from XSLT? I cant find any help online. It has been more than a week

  • Bobby 43 posts 63 karma points
    Nov 14, 2011 @ 11:53
    Bobby
    0

    Hi Shahnawaz,

    I am also having the same problem that you are having. i just found out a link which might be helpful to you.If you have already solved that issue, can you please provide me the working code.

    http://www.mortenbock.dk/blog/2007/02/08/using-xslt-search-with-multiple-dropdowns.aspx

     

    Regards,

    Bobby

  • Rich Green 2246 posts 4008 karma points
    Nov 14, 2011 @ 12:13
    Rich Green
    0

    Hey,

    You can just us umbraco.library:Request('yourValue') in XSLT

    Rich

  • Rich Green 2246 posts 4008 karma points
    Nov 14, 2011 @ 12:16
    Rich Green
    0

     

    Just to be clear, getting this value in XSLT is not tricky, if it's not working then it's probably something to do withyour form.

    Essentially this works the same as any html form (have you named your dropdown element as well as given it an ID?)

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft