Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    148

    Unanswered: Alternating Row Color Question - receiving error :(

    Hi everyone. I'm tryin to set up some alternating row colors - something that is normally painless however I am having some kind of issue with the nesting of conditional statements I believe. I get an expected statement error on line 252 (which has asterisks in front of it in the code below)
    Any help would be appreciated - the code is below.....




    <html>
    <head>
    <title>Tool</title>

    </style>
    </head>
    <%

    dim row, bgcolor
    row = 1

    do until RS.EOF
    if (row mod 2) = 1 then
    bgcolor = "#FFFFFF" 'Main Color
    else
    bgcolor = "#CCCCCC" 'Alternate Color
    end if

    row = row + 1


    %>
    <body>


    <img SRC="images/commstore_banner.gif" WIDTH="600" HEIGHT="50">
    <hr size="2" color="Red">[<a HREF="http://northeast.corp.bam.com/commstore/reports.htm">Northeast Area Automated Sales Reporting</a>]<p>

    <a HREF="query.asp">New Search</a><p>

    <%=fieldFound%><p>

    <% If RS.EOF Then
    Response.Write "<FONT face=Arial color=Red><B>No Results</B></FONT>"
    Else
    RS.MoveFirst
    count = 0 %>

    <table width="750" border="1" cellspacing="1" cellpadding="3" bgcolor="Red">
    <tr bgcolor="White">
    <td class="Main" align="center">Transaction
    </td>
    <td class="Main" align="center">Customer
    ID</td>
    <td class="Main" align="center">Line #</td>
    <td class="Main" align="center">Transaction
    Type</td>
    <td class="Main" align="center">Number</td>
    <td class="Main" align="center">Sales Rep
    ID</td>
    <td class="Main" align="center">Price Plan
    Code</td>
    <td class="Main" align="center">Churn Flag</td>
    <td class="Main" align="center">Outlet ID</td>
    </tr>


    <%Do Until RS.EOF%>
    <tr bgcolor=<%=bgcolor%>>
    <td class="Data"><%=RS.Fields("field1")%></td>
    <td class="Data"><%=RS.Fields("field2")%></td>
    <td class="Data"><%=RS.Fields("field3")%></td>
    <td class="Data"><%=RS.Fields("field4")%></td>
    <td class="Data"><%=RS.Fields("field5")%></td>
    <td class="Data"><%=RS.Fields("field6")%></td>
    <td class="Data"><%=RS.Fields("field7")%></td>
    <td class="Data"><%=RS.Fields("field7")%></td>
    <td class="Data"><%=RS.Fields("field7")%></td>
    </tr>



    <% count = count + 1
    RS.MoveNext
    Loop %>
    </table>



    <% End If
    %>

    </body>
    </html>

    **************the line with "end if" on it is number 252
    <%
    End If
    %>

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Remove this line....

    do until RS.EOF

    and move this set of lines into your other loop further down....

    if (row mod 2) = 1 then
    bgcolor = "#FFFFFF" 'Main Color
    else
    bgcolor = "#CCCCCC" 'Alternate Color
    end if

    Also, you could make this a little better if you drop the whole row incrementing and do something like...

    bgcolor = ""
    if bgcolor = "#CCCCCC" then
    bgcolor = "#FFFFFF" 'Main Color
    else
    bgcolor = "#CCCCCC" 'Alternate Color
    end if

    Mean you don't have the unnecessary overhead of the row variable that you used to.....

Posting Permissions

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