Copied to clipboard

Flag this post as spam?

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


  • Aaron 2 posts 22 karma points
    Oct 08, 2011 @ 06:57
    Aaron
    0

    create drop down menu in xslt

    I am able to create a simple drop down menu, but i want get ahead i am trying to apply background color to each option in select tag and value to for it.

    <select>
    <option value = "01" style="background-color:red;"> Town hall Station </option>
    <option value = "02" style="background-color:blue;"> central Station </option>
    <option value = "03" style="background-color:yellow;"> auburn Station </option>
    </select>

    xml file

    <routes>
    <route id = 01>
    <name>Town hall station</name>
    <color>red</color>
    </route>

    <route id = 02>
    <name>central station</name>
    <color>blue</color>
    </route>


    <route id = 03>
    <name>auburn station</name>
    <color>yellow</color>
    </route>
    </routes>

    please if anyone has solution post me.

    regards

    Aaron


  • Rich Green 2246 posts 4008 karma points
    Oct 08, 2011 @ 08:35
    Rich Green
    0

    Hi Aaron,

    Welcome to the Umbraco forum!

    You'll need something like this where 1010 is the node id of your 'Routes' node (there are many different ways to get this node value but for now this should get you started

    (Not tested)

    <select>

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1010)/* [@isDoc and string(umbracoNaviHide) != '1']">

      <option value="{id}" style="background-color:{color};">

          <xsl:value-of select="@nodeName"/>

      </option>

    </xsl:for-each>

    </select>

    Rich

  • Rodion Novoselov 694 posts 859 karma points
    Oct 08, 2011 @ 10:04
    Rodion Novoselov
    0

    Hi. Also, afaik, styling a separate options of a 'select' element doesn't work as expected in different browsers. 

  • Aaron 2 posts 22 karma points
    Oct 08, 2011 @ 11:55
    Aaron
    0

    Rodion

    Thank you that should help.

    regards

    Aaron

     

Please Sign in or register to post replies

Write your reply to:

Draft