Alternate bgcolor for table rows

Results 1 to 6 of 6

Thread: Alternate bgcolor for table rows

  1. #1
    Trish Guest

    Default Alternate bgcolor for table rows

    Does anyone know how I can write a loop that alternates between two colors (eg grey and white) for table rows in a recordset?

  2. #2
    Join Date
    Dec 1969
    Posts
    433

    Default RE: Alternate bgcolor for table rows

    I have had success by using style sheets.<BR><BR>&#060;STYLE media="all"&#062;<BR>&#060;!--<BR>TR.clsEven {background-color: #E0E0E0}<BR>TR.clsOdd {background-color: white}<BR>--&#062;<BR>&#060;/STYLE&#062;<BR><BR>then &#060;TR CLASS="&#060;%=GetNextRow%&#062;"&#062; for each row of the table, where GetNextRow just toggles a variable, and returns alternating class names<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    572

    Default RE: Alternate bgcolor for table rows

    &#060;%if a="#ffffcc" then<BR> a= "#ffffff"<BR> else<BR> a="#ffffcc"<BR> end if%&#062;<BR> &#060;td width="200" valign="top" bgcolor=&#060;%=a%&#062;&#062;

  4. #4
    generic Guest

    Default RE: Alternate bgcolor for table rows

    &#060;%<BR> i=0<BR> while not rs.eof<BR> i=i+1<BR> if i mod 2 = 0 then<BR>%&#062;<BR> &#060;tr bgcolor="silver"&#062;<BR>&#060;% else %&#062;<BR> &#060;tr bgcolor="white"&#062;<BR>&#060;% end if %&#062;<BR> &#060;td&#062;whatever&#060;/td&#062;<BR>&#060;% rs.movenext %&#062;<BR> &#060;/tr&#062;<BR>&#060;% wend %&#062;


  5. #5
    Michael Swanson Guest

    Default RE: Alternate bgcolor for table rows

    As if we need one more method:<BR><BR>iFlag = 0<BR>iFlag = 1 - iFlag<BR>If iFlag = 0 Then<BR> sBGColor = "#EFEFEF"<BR>Else<BR> sBGColor = "#FFFFFF"<BR>End If<BR><BR>This works great for a toggle.<BR><BR>Michael Swanson, MCSE, MCP+Internet<BR>Webmaster<BR>Donnelly Corporation<BR>mike.swanson@donnelly.com<BR>

  6. #6
    trish Guest

    Default RE: Alternate bgcolor for table rows

    thanks to everyone who responded to this query!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •