Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alternate row colurs

Status
Not open for further replies.

plork123

Programmer
Mar 8, 2004
121
GB
dept boss
----------------------------------
accounts Marge Simpson
finance AN Other
marketing Marge Simpson
IT Someone else


When I display the data on the page, it's displayed like this

boss dept
----------------------------------
Marge Simpson accounts
marketing
finance AN Other
IT Someone else


Each row has to have alternate colours, so like this

boss dept
----------------------------------
Marge Simpson accounts dark background colour
marketing dark background colour
finance AN Other light background colour
IT Someone else dark background colour


Because I have 2 rows for Marge Simpson, making the rows alternate colurs isn't working. Does anyone have any ideas of how I can do this

Thanks in advance




At the moment I'm doing other pages like this, which works fine (FYI i'm also using jaascript)

Code:
<xsl:variable name=\"rowColour\">
	<xsl:choose>
		<xsl:when test=\"position() mod 2 = 0\">
			dark background colour
		</xsl:when>
		<xsl:otherwise>
			light background colour
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>
 
try this:

Code:
<xsl:variable name='rowColour'>
    <xsl:choose>
        <xsl:when test='position() mod 2 = 0'>
            <xsl:value-if select='dark background colour'/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-if select='light background colour'/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable>


and use the variable to create your style sheet


hth

simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top