Alternate row colors


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. '************************************************
  2. '
  3. ' To use it put the code like this on your loop:
  4. '
  5. ' <%counter = counter + 1%>
  6. ' <tr bgcolor="<%=Acolor(counter,"#a0a0a0","#e0e0e0")%>">
  7. ' <td>Data</td>
  8. ' </tr>
  9. '
  10. ' n is the external counter
  11. ' col is the first color in hex format
  12. ' col2 is the second color in hex format, you can leave it empty
  13. '************************************************
  14.  
  15. function Acolor(n,col,col2)
  16.  
  17. num = 0
  18. num = n mod 2
  19.  
  20. if col2 = "" then col2 = "#ffffff"
  21.  
  22. if num = 0 then
  23. Acolor = col
  24. else
  25. Acolor = col2
  26. end if
  27.  
  28. end function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.