..


Sponsored Links

Cells in alternating colors

Article written by Luca Ruggiero

In Article Connect to a DB using CFML we saw how to connect to a generic database with CFML and how to extract data from a table using a simple SQL string.

The appearance of our report we take action now by viewing the data in cells in alternating colors, to make it more visually attractive and stylistically more readable.

Let's create a CSS style sheet with two classes to use for the background color of the cells and the odd






 . A







 {



    



 background-color: # FFFFFF;







 }







 . B







 {



    



 background-color: # EEEEEE;







 }



The videos show the query use the MOD operator controlling the value of the current record is 2-modular, control returns a Boolean value that returns true or false in alternating rows, leaving us to assign the CSS classes and a one line is not, returning on the screen the desired effect.

Let's see an example






 <table align="center" width="100" border="1">



    



 <CFOUTPUT Query="Q">



    



 <tr class="#IIF(Q.CurrentRow MOD 2, DE('A'), DE('B'))#">



        



 Q. <td> # FieldName # </ td>



    



 </ Tr>



    



 </ Cfoutput>







 </ Table>



HTML code returned by the server looks like this





 <table align="center" width="100" border="1">





    



 <tr class="A">



        



 <td> Luke </ td>



    



 </ Tr>





    



 <tr class="B">



        



 <td> Max </ td>



    



 </ Tr>





    



 <tr class="A">



        



 <td> Claudio </ td>



    



 </ Tr>





    



 <tr class="B">



        



 <td> James </ td>



    



 </ Tr>









 </ Table>



In the same category ...
E-Learning
ASP (Advanced) ASP (Advanced)
Full course for creating dynamic Web sites. From 39 €.
AutoCAD (eBook) AutoCAD (eBook)
Creation of architectural structures. At only 29 €.
Photoshop (Course) Photoshop (Course)
Web graphics and photo editing with the popular Adobe Photoshop. From 49 €.
Sponsored Links