我想控制出id="td2"的行不显示,可是为什么不能实现呢?IE提示缺少对象,希望有人能帮我看出错误所在....苦恼中....<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../admin/admin_conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>分页模块编写</title>
<style type="text/css">
td{
text-align:center;
padding-top:10px;
}
</style>
<script language="javascript">
document.getElementById("td2").style.display="none";
</script>
</head><body>
<%
'response.Write("Hello World!") Okay,Test sucessfully
set rs = server.CreateObject("adodb.recordset")
sql = "select * from news"
rs.open sql,conn,1,1
'response.Write(rs.recordcount) Okay,Test Totalcounts
pagesizes = 10 '每页显示的列表条数
totalnum = rs.recordcount '总的记录数
totalpages = totalnum mod pagesizes'用总的记录数除以每页显示的记录数来获得一共可以显示的页数
rs.absolutepage = 1 '当前显示页
if totalpages <> 0 then
totalpages = (totalnum-totalpages)/pagesizes+1
else
totalpages = totalnum/totalpages
end if
response.Write(pagesizes&"<br>")
response.Write(totalnum&"<br>")
response.Write(totalpages&"<br>")
%>
<table align="center" cellpadding="0" cellspacing="0" width="100%">
<%
i = 1
rs.movefirst
if not rs.eof and rs.bof then
response.Write("对不起,数据库暂时没有数据!")
else
do while not rs.eof
%>
<tr <% response.Write("id=""td"&i&"""") %> <% response.Write("name=""td"&i&"""") %>>
<td><%=rs(0)%></td><td><%=rs(1)%></td><td><%=rs(2)%></td><td><%=rs(3)%></td><td><%=rs(4)%></td><td><%=rs(5)%></td>
</tr>
<%m = i mod 2
if m <> 0 then
i = i+1
else
i = i-1
end if
rs.movenext
loop
end if
%>
</table>
</body>
</html>
<!--#include file="../admin/admin_conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>分页模块编写</title>
<style type="text/css">
td{
text-align:center;
padding-top:10px;
}
</style>
<script language="javascript">
document.getElementById("td2").style.display="none";
</script>
</head><body>
<%
'response.Write("Hello World!") Okay,Test sucessfully
set rs = server.CreateObject("adodb.recordset")
sql = "select * from news"
rs.open sql,conn,1,1
'response.Write(rs.recordcount) Okay,Test Totalcounts
pagesizes = 10 '每页显示的列表条数
totalnum = rs.recordcount '总的记录数
totalpages = totalnum mod pagesizes'用总的记录数除以每页显示的记录数来获得一共可以显示的页数
rs.absolutepage = 1 '当前显示页
if totalpages <> 0 then
totalpages = (totalnum-totalpages)/pagesizes+1
else
totalpages = totalnum/totalpages
end if
response.Write(pagesizes&"<br>")
response.Write(totalnum&"<br>")
response.Write(totalpages&"<br>")
%>
<table align="center" cellpadding="0" cellspacing="0" width="100%">
<%
i = 1
rs.movefirst
if not rs.eof and rs.bof then
response.Write("对不起,数据库暂时没有数据!")
else
do while not rs.eof
%>
<tr <% response.Write("id=""td"&i&"""") %> <% response.Write("name=""td"&i&"""") %>>
<td><%=rs(0)%></td><td><%=rs(1)%></td><td><%=rs(2)%></td><td><%=rs(3)%></td><td><%=rs(4)%></td><td><%=rs(5)%></td>
</tr>
<%m = i mod 2
if m <> 0 then
i = i+1
else
i = i-1
end if
rs.movenext
loop
end if
%>
</table>
</body>
</html>
这行改成
<tr id="td<%=i%>" name="td<%=i%>">
另外补充:请注意代码规范,你的写法有可能会引出JS异常,导致JS运行中断
document.getElementsByName;设置name属性,然后获取 遍历