网页错误:缺少对象/'null'为空或不是对象
主要问题是:1、选了某些checkbox后,按删除,不能删除,提示"网页上有错误"--'null'为空或不是对象
2、勾了“全部选择/取消”复选框,不执行全选功能,也提示"网页上有错误"--缺少对象
代码如下:(望好心人解答,或给点提示,太感谢了!)
<!--#include file="conn.inc"-->
<html>
<head>
<script language="javascript">
function editit(id)
{
page="adminhouseedit.asp?id="+id
window.open (page,'查看编辑题目','width=560,height=360')
}//编辑题目弹出固定大小的窗口
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}//选择题目
function viewit(myform)
{
if (document.viewaddform.subjectview.value!="")
subject=document.viewaddform.subjectview.value;
else
subject="所有";
if (document.viewaddform.typeadd.value!="")
type=document.viewaddform.typeadd.value;
else
type="所有";
result="浏览<"+subject+">题库中<"+type+">题目?"
if (confirm(result))
{
myform.action="adminhouse.asp";
myform.submit();
}
}
function searchit(myform)
{
if (document.viewaddform.subjectview.value!="")
subject=document.viewaddform.subjectview.value;
else
subject="所有";
if (document.viewaddform.typeadd.value!="")
type=document.viewaddform.typeadd.value;
else
type="所有";
if (document.viewaddform.mykey.value!="--关键字--")
mykey=document.viewaddform.mykey.value;
else
mykey="";
result="在<"+subject+">题库中<"+type+">题目中搜索关键字<"+mykey+">?"
if (confirm(result))
{
myform.action="adminhouse.asp";
myform.submit();
}
}//按照关键字查找
function addit(myform)
{
if (document.viewaddform.subjectview.value!="" & document.viewaddform.typeadd.value!=""){
result="添加"+document.viewaddform.typeadd.value+"题目到"+document.viewaddform.subjectview.value+"题库?"
if (confirm(result))
{
myform.action="adminhouseadd.asp";
myform.submit();
}
}
else
alert("请首先选择科目和题目类型")
}//添加题目
function delit(myform)
{
if (confirm ("是否从题库中删除所选项?"))
{
window.location="adminhousedel.asp";
<!-- myform.action="adminhousedel.asp"; -->
myform.submit();
}
}//删除题目
</script>
<link rel="stylesheet" type="text/css" href="mycss.css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body>
<table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2" height="25">
<tr>
<td width="100%">当前位置:<a href="news.asp">系统管理</a> > 题库管理</td>
</tr>
</table>
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" id="AutoNumber2" bgcolor="#E1E1E1" width="100%">
<form name="viewaddform" method="POST" action="adminhouse.asp">
<tr>
<td><select size="1" name="subjectview">
<option selected>--选择科目--</option>
<% sql="select * from examsubject"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
do while not rs.eof %>
<option value="<%=rs("examsubject")%>"><%=rs("examsubject")%></option>
<% rs.movenext
loop
rs.close %></select><select size="1" name="typeadd">
<option selected>--题型--</option>
<option value="单选题">单选题</option>
<option value="多选题">多选题</option>
<option value="判断题">判断题</option>
</select><input type="submit" value="浏览" name="I3" onclick="viewit(this.form)" class="s02">
<input type="submit" value="添加题目" name="I6" onclick="addit(viewaddform)" class="s02">
<input type="text" name="mykey" size="10" value="--关键字--" onfocus="this.select()" class="s01">
<input type="submit" value="查询" name="I7" onclick="searchit(this.form)" class="s02"></td>
</tr>
</form>
</table>
<form name="viewdatabase" method="post">
</form>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="30">
<tr>
<td>
<p align="right">
<input type="checkbox" name="chkall" value="on" onclick="CheckAll(this.form)" style="font-size: 9pt; color: #000000">全部选择/取消
<input type="submit" value="删除所选项" name="I3" onclick="delit(this.form)" class="s02">
</td>
</tr>
</table>
<table border="1" cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#C0C0C0" width="100%" id="AutoNumber1">
<tr>
<td width="30" align="center" bgcolor="#E1E1E1" height="20"></td>
<td width="30" align="center" bgcolor="#E1E1E1"><b>序号</b></td>
<td align="left" bgcolor="#E1E1E1" width="120">
<p align="center"> <b>科目名称</b></td>
<td align="left" bgcolor="#E1E1E1">
<p align="center"><b>题目内容</b></td>
<td align="left" bgcolor="#E1E1E1" width="30">
<p align="center"><b>操作</b></td>
</tr>
<%
subjectview=request("subjectview")
typeadd=request("typeadd")
mykey=request("mykey")
if subjectview="--选择科目--" or subjectview="" then
subjectview="%"
end if
if typeadd="--题型--" or typeadd="" then
typeadd="%"
end if
if mykey= "--关键字--" or mykey="" then
mykey="%"
end if
PageCount=0
sql="select * from examhouse where subject like '"& subjectview &"' and type like '"& typeadd &"' and question like '" & mykey &"'"
set rs=conn.execute(sql)
while not rs.eof
PageCount=PageCount+1
rs.movenext
wend
sql="select * from examhouse where subject like '"& subjectview &"' and type like '"& typeadd &"' and question like '" & mykey &"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
on error resume next
PageSize = 10
PageCount=(PageCount+PageSize-1)\PageSize
Page = CLng(Request("Page"))
'分页显示
If not Page >1 Then Page = 1
If Page > PageCount Then Page = PageCount
i=page+(page-1)*9
rs.AbsolutePage = Page
For iPage = 1 To PageSize
%>
<tr>
<td align="center" bgcolor="#E1E1E1">
<input type="checkbox" name="id" value="<%=rs("id")%>"></td>
<td align="center"><%=i%></td>
<td align="left"><%=rs("subject")%></td>
<td align="left"><%=rs("question")%></td>
<td align="left">
<p align="center"><a href="javascript:editit(<%=rs("id")%>)">
<img border="0" src="images/edit.gif" alt="查看/编辑"></a></td>
</tr>
<%
rs.MoveNext
If rs.EOF Then Exit For
i=i+1
Next
%>
</table>
<div ALIGN="right">
<table>
<form ACTION="<%=Myself%>?sujectview=<%=subjectview%>&typeadd=<%=typeadd%>&mykey=<%=mykey%>%>" METHOD="GET">
<tr>
<td>
<p ALIGN="right"><%If Page <> 1 Then '如果不是位于第一页%>
<a href="<%=Myself%>?Page=1&sujectview=<%=subjectview%>&typeadd=<%=typeadd%>&mykey=<%=mykey%>">
第一页</a>
<a HREF="<%=Myself%>?Page=<%=(Page-1)%>&sujectview=<%=subjectview%>&typeadd=<%=typeadd%>&mykey=<%=mykey%>">
上一页</a>
<%
End If
If Page <> PageCount Then ' 如果不是位于最后一页
%> <a HREF="<%=Myself%>?Page=<%=(Page+1)%>&sujectview=<%=subjectview%>&typeadd=<%=typeadd%>&mykey=<%=mykey%>">
下一页</a>
<a HREF="<%=Myself%>?Page=<%=PageCount%>&sujectview=<%=subjectview%>&typeadd=<%=typeadd%>&mykey=<%=mykey%>">
最后一页</a> <% End If %> <font SIZE="2">输入页次:</font><input NAME="Page" SIZE="3" CLASS="s01">
<font SIZE="2">页次:</font><font COLOR="Red" SIZE="2"><%=Page%>/<%=PageCount%></font></p>
<p></td>
</tr>
</form>
</table>
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
[解决办法]
两个按钮明显在form外
怎能用this.form,直接用form名就可以了
另外js中的注释用//或/**/