In a very simple way we will see how we can have alternating row colors and when the mouse hovers a specific row, it gets highlighted.
We will CSS for our tr tags and we will be doing this in a very simple way. Below is the detailed description of how we can can do this.
First of all we need the following CSS:
<style>
tr.rowOdd {background-color: #CCCCCC;}
tr.rowEven {background-color: #E7E7E7;}
tr.rowHighlight {background-color: #FFFF99;}
</style>
Now in our page we will define query cfoutput as:
<cfoutput query="recordset">
<cfif currentRow MOD 2>
<cfset rowClass = "rowOdd" />
<cfelse>
<cfset rowClass = "rowEven" />
</cfif>
<tr class="#rowClass#"
onmouseover="this.className='rowHighlight'"
onmouseout="this.className='#rowClass#'">
<td>#recordset.catName#</td>
</tr>
</cfoutput>
That's all we have to do to make it work. It is easy and simple enough.
+