0 Replies - 1394 Views - Last Post: 23 March 2005 - 02:46 PM

#1 skyhawk133   User is offline

  • Head DIC Head
  • member icon

Reputation: 1964
  • View blog
  • Posts: 20,421
  • Joined: 17-March 01

Alternate Row Colors

Posted 23 March 2005 - 02:46 PM

Description: Read comments for details on use. Alternates colors every other row when outputting in coldfusion. Uses a function to seperate logic from display.
<!--- Paste this function in a component or .cfm page --->

     <cffunction name="AlternateColor" access="public" output="false" returntype="string">
          <!--- Arguments --->
          <cfargument name="color1" type="string">
          <cfargument name="color2" type="string">
          <cfargument name="row" type="numeric">
          
          <!--- Alternate Colors --->
          <cfif arguments.row MOD 2>
               <cfset thiscolor = arguments.color1>
          <cfelse>
               <cfset thiscolor = arguments.color2>
          </cfif>
                    
          <!--- Return The Color --->
          <cfreturn thiscolor>
     </cffunction>


<!--- Inside a loop (query, cfoutput, or otherwise) paste this code. 
Change colors and row identifier to suit needs --->

<cfset color = AlternateColor(color1="##FFFFFF", color2="##F7F7F7", row=#query.CurrentRow#)>





Is This A Good Question/Topic? 0
  • +

Page 1 of 1