|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
creating every other row with green background
Hi
Just wondering how would I create a table the at displays every other row (odd row) cells as green using and <xsl:if> below is my code <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <HTML> <BODY> <p align="left"><font color="#FF0000"><strong>Airport Flight Schedule Leslie Ho</strong></font></p> <div align="left"> <TABLE border="1"> <tr> <th rowspan="2">Airline</th> <th colspan="4">To</th> <th colspan="3">From</th> </tr> <tr> <th>Airport</th> <th>Date</th> <th>ATime</th> <th>Price($)</th> <th>Airport</th> <th>Date</th> <th>Dtime</th> </tr> <xsl:for-each select="FLIGHT_SCHEDULE/FLIGHT"> <xsl:sort select="TO/DATE" data-type="text" order="ascending"/> <TR> <TD><xsl:value-of select="AIRLINE"/><xsl:value-of select="AIRLINE/@number"/></TD> <TD><xsl:value-of select="TO/AIRPORT"/></TD> <TD><xsl:value-of select="TO/DATE"/></TD> <TD><xsl:value-of select="TO/ATIME"/></TD> <TD><xsl:value-of select="TO/PRICE"/></TD> <TD><xsl:value-of select="FROM/AIRPORT"/></TD> <TD><xsl:value-of select="FROM/DATE"/></TD> <TD><xsl:value-of select="FROM/DTIME"/></TD> </TR> </xsl:for-each> </TABLE> <font color="#336633"><xsl:text></xsl:text></font></div> </BODY> </HTML> </xsl:template> </xsl:stylesheet> thanx getchoo |
|
#2
|
|||
|
|||
|
I'd think something like:
<xsl:for-each select="FLIGHT_SCHEDULE/FLIGHT"> <xsl:sort select="TO/DATE" data-type="text" order="ascending"/> <TR> <xsl:attribute name="style"> <xsl:if test="position() mod 2 = 0"> background-color: evencolor; </xsl:if> <xsl:if test="position() mod 2 = 1"> background-color: oddcolor; </xsl:if> </xsl:attribute> Would do it. FYI, the CSS3 spec calls for an :nth-child psuedo-class, which would make this definable through CSS and not require any extra markup: tr:nth-child(odd) { background-color: gray; } This is one CSS3 selector though that Mozilla doesn't support. ![]() (Well, nor does any other web browser in existance) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > creating every other row with green background |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|