像这个论坛贴子列表一样,一行底色白色,一行底色灰色怎么写的?

mydushang 2006-08-28 11:38:32
像这个论坛贴子列表一样,一行底色白色,一行底色灰色怎么写的?

<%
set rs=server.createobject("adodb.recordset")
sqltext="select top 10 * from hyqy order by id desc"
rs.open sqltext,conn,1,1
%>
<table border="0" width="100%">
<%do while not rs.eof%>
<tr>
<td>·<a href="viewnews.asp?id=<%=rs("id")%>">
<% if len(trim(rs("name")))>13 then
response.write left(trim(rs("name")),13)&""
else
response.write trim(rs("name"))
end if%></a></td>
</tr>
<%rs.movenext
loop%>
</table>
只知道这样读出来,底色都一样的.
...全文
282 9 打赏 收藏 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
飘零雾雨 2006-08-28
  • 打赏
  • 举报
回复
<%
if not rs.eof then
dim i
i=0
do while not rs.eof
i=i+1
%>
<tr <%if i mod 2 = 0 then%>bgcolor="#efefef"<%else%>bgcolor="#ffffff"<%end if%>><td>内容</td></tr>
<%
rs.MoveNext
loop
end if
%>

或:

<style>
tr{
background:expression(this.rowIndex%2==0?"#fff":"#efefef");
}
</style>
leohuang 2006-08-28
  • 打赏
  • 举报
回复
用css就可以了

<style>
tr{
background:expression(this.rowIndex%2==0?"#fff":"#f0f0f0");
}
</style>
gq 2006-08-28
  • 打赏
  • 举报
回复
<%
do while not rs.EOF
if i mod 2 then
%>


<table width=98% border="0" height=20 cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="25" align="center"><font color=green><b><%if rs("finish")=0 then%>?<%else%>√<%end if%></b></font></td>
<td><a href=article.asp?id=<%=rs("titleid")%> target=_blank><%=rs("title")%></a>(<%=rs("user")%>)</td>
<td width="70" align="right"><%=rs("count")%></td>
<td width="50" align="right"><%=rs("reply")%></td>
<td width="120" align="center"><%=right(rs("Lastposttime"),len(rs("Lastposttime"))-2)%></td>
<td width="40" align="center"><a href=admin_article.asp?id=<%=rs("titleid")%> target=_blank>管理</a></td>
</tr>
</table>
<%else%>
<table width=98% bgcolor=#DEE3F7 height=20 border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="25" align="center"><font color=green><b><%if rs("finish")=0 then%>?<%else%>√<%end if%></b></font></td>
<td><a href=article.asp?id=<%=rs("titleid")%> target=_blank><%=rs("title")%></a>(<%=rs("user")%>)</td>
<td width="70" align="right"><%=rs("count")%></td>
<td width="50" align="right"><%=rs("reply")%></td>
<td width="120" align="center"><%=right(rs("Lastposttime"),len(rs("Lastposttime"))-2)%></td>
<td width="40" align="center"><a href=admin_article.asp?id=<%=rs("titleid")%> target=_blank>管理</a></td>
</tr></table>
<%
end if
i=i+1
rs.MoveNext
loop
%>
mydushang 2006-08-28
  • 打赏
  • 举报
回复
问题好了,

但我给大伙分的时候给不了,提示"贴子回复次数大于跟给分次数 ",不知咋整?
atmo 2006-08-28
  • 打赏
  • 举报
回复
第一次见 厉害

用CSS最简单:
<style>
tr{
background:expression(this.rowIndex%2==0?"#fff":"#efefef");
}
</style>
underone 2006-08-28
  • 打赏
  • 举报
回复
都被人说了,接分
flyingsnowy 2006-08-28
  • 打赏
  • 举报
回复
<%
do while not rs.eof '开始
if i mod 2 then
bbcolor="#F0F0F0"
else
bbcolor="#ffffff"
end if
%>
<tr bgcolor=<%=bbcolor%>> <!--以下和你代码一样-->

<td>·<a href="viewnews.asp?id=<%=rs("id")%>">
<% if len(trim(rs("name")))>13 then
response.write left(trim(rs("name")),13)&""
else
response.write trim(rs("name"))
end if%></a></td>
</tr>
<%rs.movenext
loop%>
……
xzr2004 2006-08-28
  • 打赏
  • 举报
回复
用CSS最简单:
<style>
tr{
background:expression(this.rowIndex%2==0?"#fff":"#efefef");
}
</style>

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧