[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] alternating table background colour in an for-each 'loop'
Subject: RE: [xsl] alternating table background colour in an for-each 'loop' From: "Tim Watts" <timw@xxxxxxx> Date: Thu, 19 Jul 2001 16:23:42 +1000 |
Michael, You may have found a solution now. I began a reply earlier, but got side-tracked by work!!! Basically you can change the colours of rows by using the position() function and mod (mod being an math term which gives the remainder if a division. ie. 13 mod 4 would be 1. 13 can be divided by 4 three times and leaves a remainder of 1.) An example is shown below, using a CSS. <xsl:template match="products"> <xsl:choose> <xsl:when test="position() mod 4 = 0"> <tr class="red"> <xsl:call-template name="showproducts" /> </tr> </xsl:when> <xsl:when test="position() mod 4 = 1"> <tr class="green"> <xsl:call-template name="showproducts" /> </tr> </xsl:when> <xsl:when test="position() mod 4 = 2"> <tr class="blue"> <xsl:call-template name="showproducts" /> </tr> </xsl:when> <xsl:when test="position() mod 4 = 3"> <tr class="pink"> <xsl:call-template name="showproducts" /> </tr> </xsl:when> </xsl:choose> </xsl:template> Hope that that provides enough info to go on, Cheers, Tim Watts :) -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Michael Bauerfeld Sent: Thursday, 19 July 2001 11:31 AM To: xsl list Subject: [xsl] alternating table background colour in an for-each 'loop' Hi everyone, I'm trying to alternate the background colour of table rows (e.g. row1=green, row2=blue, row3=green, row4=blue, ...) for a for-each loop. Is there an easy way to achieve this? I've tried to get the element position so I can check if it is even or not. But it looks like I can't get the absolute position of an element in a list with 'position()' inside a 'for-each' loop. Any ideas?? Thanks, -michael XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] alternating table backgro, Serdar Kilic | Thread | Re: [xsl] alternating table backgro, David Carlisle |
Re: [xsl] XSL-Related Tutorials at , mhkay | Date | Re: [xsl] xsl:value-of select betwe, Jeni Tennison |
Month |
Keywords