鲁鲁修插曲:ASP表格循环

来源:百度文库 编辑:神马品牌网 时间:2024/03/29 06:13:13
我想做个这样的。 大家知道循环输出表格的 我现在想要循环2中颜色不一样的<tr>。我希望第一行的颜色和第二行不一样,而第三行的颜色和第一行的颜色一样的, 第四行的颜色和第二行的颜色一样的。 也就是有2行色循环输出。 这样怎么做?求解!

css样式做的。
<style type="text/css">
<!--
.tr1 {
background-color: #0099FF;
}
.tr2 {
background-color: #CCCCCC;
}
-->
</style>
<table width="200" border="1" cellspacing="1" cellpadding="0">
<%
for i= 1 to 10
if i mod 2 = 0 then
response.Write("<tr class='tr1'>")
else
response.Write("<tr class='tr2'>")
end if
%>
<td height="25"> </td>
</tr>
<%
next
%>
</table>

<%For i = 1 To x: If i / 2 = Int(i / 2) Then color = "red" Else color = "blue"%>
<tr>
<td bgcolor="<%= color%>"><%= i%></td>
</tr><%Next%>

实例
<table border=1 width=500>
<%

for j = 1 to 10
if j mod 2 <> 0 then
response.write "<tr><td bgcolor=red>这是第" & j & "行<td></tr>"
else
response.write "<tr><td bgcolor=blue>这是第" & j & "行<td></tr>"
end if

next
response.write "</table>"
%>