Home > ASP Development > Alternative table colours

Alternative table colours



Hello all not been here for a while maybe im getting better or continuing to code badly who knows :P



anyways what id like to do is in my "do while" loop i want to create different background colours so its easier to read with large tables.



I know the code should be something like



If variaiable isnot true then

bgcolour = blue

Else

bg colour = red

end if



i am, however, not quite sure ont he correct syntax for it?

any advice appreciated

.matt

    
Guest


sorted heres how i did it incase anyone needs to know

<% if bgcolor = true then %>

class = "alt1"

<% bgcolor = false

Else%>

class = "alt2"

<% bgcolor = true

End if %>



.matt

Was this answer helpful ? Yes No   
Guest


close, but your cigar is quite small. meaning, nice but it's limited to two colors only. if you'll ever want more colors, consider such code:

Code:


  <%
  bgCounter=0
  colorsCount=2
  Do Until something happens
  %>
  class =  "alt<%=(bgCounter Mod colorsCount)+1%>"
  <%
     bgCounter=bgCounter+1
  Loop
  %>
  



all you have to do is define how many colors you have, have proper "alt1", "alt2",... classes and increment counter in each iteration of the loop. the Mod operator is actually the Modulo function - remember, from highschool?

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved