终结者 创世纪 国语:ASP中表格样式的问题

来源:百度文库 编辑:高考问答 时间:2024/04/29 21:22:12
我在ASP中用循环的方法调用新闻..
但是我调用出来每条新闻所在的表格背景色都一样的: 例如:
白色
白色
白色
白色
......
我觉得这样不好看
我想调用出来的表格背景色是 例如:
白色
黑色
白色
黑色
......

不知道怎样实现...请给出事例代码..谢谢

<%
for i = 0 to rs.RecordCount - 1
if i mod 2 = 0 then
tdbgcolor = \"#ffffff\"
else
tdbgcolor = \"#000000\"
end if
%>
<td bgcolor=\"<%=tdbgcolor%>\"></td>
<%
rs.MoveNext
next
%>

濂芥柟娉?鍚屾剰

支持矩阵设置,翻页的格式显示!
<%
sub showNews(sql,cols,rows,ipage,isShowBookMark,path)
dim rs,page_size,icol
if cols="" or not isNumeric(cols) then cols = 1
if cols<=0 then cols = 1
if rows="" or not isNumeric(rows) then rows = 1
if rows<=0 then rows=1
if ipage="" or not isNumeric(ipage) then ipage=1
if ipage<=0 then ipage=1

page_size = cols * rows
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
response.write "<table width=100% border=0 cellpadding=0 cellspacing=0>" & VBCRLF
if rs.eof or rs.bof then
response.write "<tr><td width=100% height=50 align=center valign=middle class='red'>暂时没有信息!</tr>" & VBCRLF
response.write "</table>" & VBCRLF
exit sub
end if
rs.pageSize = page_size
if int(ipage) > int(rs.pageCount) then ipage = rs.pageCount
rs.absolutePage = ipage

icol = 0
while not rs.eof
if icol mod cols = 0 then
response.write "<tr>" & VBCRLF
end if
response.write "<td width=" & int(100/cols) & "% height=20 align=left valign=middle>" & VBCRLF
%> ¤ <a href="readData.asp?page=<%=ipage%>&id=<%=rs("id")%>" style="color:#000000"><%=autoCut(rs("title"),20)%></a> [<span class="newstime"><%=dateValue(rs("post_time"))%></span>]
<%
response.write "</td>" & VBCRLF
icol = icol + 1
if icol mod cols = 0 then
response.write "</tr>" & VBCRLF
end if
rs.movenext
wend
if icol mod cols <> 0 then
response.write "<td colspan=" & int(cols - icol mod cols) & "> </td></tr>" & VBCRLF
end if
response.write "</table>"

if isShowBookMark=1 then
response.Write "<br><div style='font-size:12px;color=black'>" & VBCRLF
response.write "<br>总记录数<font color=red>"&rs.recordCount&"</font>   每页<font color=red>20</font>  "
if ipage <= 1 then
response.write "<font color=darkgray>首页 前页</font>"
else
response.write "<a href=" & path & "page=1>首页</a> <a href=" & path & "page="&page-1&">前页</a>"
end if
if int(ipage) = int(rs.pageCount) then
response.write "<font color=darkgray> 下页 末页</font>"
else
response.write " <a href=" & path & "page="&ipage+1&">下页</a> <a href=" & path & "page="&rs.pageCount&">末页</a>"
end if
response.write "    第"&ipage&"页 共"&rs.pageCount&"页"
response.write "</div>"

end if
%>
如果你看明白这段代码,那么变颜色的就不在话下了!
这段代码可以指定显示的矩阵形式!

循环外i=0

循环里
<td bgcolor=<%if i=0 then
response.write "#ffffff"
i=1
else
response.write "#ffffff"
i=0
end if
%>>rs("col")</td>

very good ,me too
there only need a flag,if the flag is true then
do while (……)
if flag then
response.write "#ffffff"
flag=not flag
else
response.write "#000000"
flag=not flag
loop
my email address is sdxy@zj.com
welcome you to write with me !

<%
dim i
i=2
%>
<% while not rs.eof %>
<% if i mod 2 =0 then %>
<tr bgcolor="#000000">
<% else %>
<tr bgcolor="#Ffffff">
<% end if %>
<% i=i+1 %>
<% rs.movenext %>
<% wend %>

有没看懂,随手写的一下看不懂再给我留言。QQ32898679