急求~asp 表格颜色交替显示

来源:百度知道 编辑:UC知道 时间:2024/05/05 06:48:32
这是从数据库里读出来的值,我想让它行与行的背景色循环交替显示。
如第一行是白色,第二行是黑色,第三行是白色,第四行是黑色···
帮忙~
<%
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "select * from chengjiao where auditing='1' order by starttime desc",conn,1,1
while not rs.eof
%>
<tr class="style1" height="25">
<td align="center"><%=left(rs("starttime"),10) %></td>
<td><%= rs("place") %></td>
<td align="center"><%= rs("construct") %></td>
<td align="center"><% if rs("picture")<>"" then %>
<a href="ghadmin/<%=rs("picture")%>" target="_blank"><%= rs("client") %></a>
<% else %>
<%= rs("client")%>
<% end if %></td>
<td align="center"

<style type="text/css">
<--
tr {background-color:expression((this.sectionRowIndex%2==0)?"#FFFFFF":"#000000")}
-->
</style>
这个加在<head></head>之间
如果在这个网页中还有其他表格的话可以改成:
<style type="text/css">
<--
tr1 {background-color:expression((this.sectionRowIndex%2==0)?"#FFFFFF":"#000000")}
-->
</style>
然后在<tr>标签中加入class=tr1

楼上的使用css 的确不错.

<%
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "select * from chengjiao where auditing='1' order by starttime desc",conn,1,1
tmp=1
while not rs.eof
if tmp=1 then
%>
<tr class="style1" height="25" bgcolor=white>
<td align="center"><%=left(rs("starttime"),10) %></td>
<td><%= rs("place") %></td&