我做一个功能.就是删除用户确认的.用
document.form1.submit() 点确认后老提示:对象不支持此属性或方法.如果把里面的代码分解出来调试就没问题.我的所有源码如下.看看错在哪里OK?弹出对话框后,点确认就说:对象不支持此属性或方法.点取消就不会.
<%@page contentType="text/html;charset=GBK"%>
<%@page import="java.sql.*"%>
<%@ include file="/public/checkvalidadmin.jsp"%>
<jsp:useBean id="conn" scope="page" class="teacher.Conn"/><%!
ResultSet rs = null;
String username = "";
String truename = "";
String password = "";
String priv_ok = "";
int priv = 0;
%><html><head>
<title>系统管理</title>
<link rel="stylesheet" href="../public/style.css"><Script Language="JavaScript">

function modcon() {//确定修改用户 
if (window.confirm("你确认要修改用户吗?"))
        {
  myform2.action="moduser.jsp";
            myform2.submit(); 
   }     }
function delcon() {//确定删除用户
if (confirm("你确认要删除用户吗?"){
myform2.action="deluser.jsp";
           document.myform2.submit();
  
}
return
      }
</Script>
</head>
<Body class="ss">
<center>
<%
priv_ok = (String)session.getAttribute("adminpriv");if(priv_ok!=null && priv_ok.equals("1")) { rs = conn.executeQuery("select * from admin");
if(!rs.next()) {
     out.println("<center>");
out.println("数据库中还没有用户!<br>");
out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
     out.println("</center>");
} else {
%> <table bgColor="#00acff" border="1" borderColorDark="#ffff00" borderColorLight="#000000" cellSpacing="1" width="80%">
<tr>
<th width="20%">用户名</th>
<th width="16%">真实姓名</th>
<th width="16%">密码</th>
<th width="16%">一般用户</th>
<th width="16%">管理员</th>
<th width="16%" colspan=2>操作</th>
</tr>
<%do {
username = rs.getString("loginname");
truename = rs.getString("truename");
password = rs.getString("password");
priv     = rs.getInt("PRIVILEDGE");
%>
<tr align="center">
      <form name="myform2" method="post" action="">
<td><%=username%></td>
<input type="hidden"   name="username" value="<%=username%>">
            <td><input type="text" name="truename" value="<%=truename%>"></td>
<td><input type="text" name="password" value="<%=password%>"></td>
<%
if(priv == 1) {
%>
<td>
<Input name="priv" type="radio" value="2" >
</td>
<td>
<Input name="priv" type="radio" value="1" checked>
</td>
<%
}else if(priv == 2) {
%>
<td>
<Input name="priv" type="radio" value="2" checked>
</td>
<td>
<Input name="priv" type="radio" value="1"  >
</td>
<%
}
%>  <td><input type="button" name="Submit1" value="修改" onclick="JavaScript:modcon()" ></td>

<td><input type="button" name="Submit2" value="删除" onclick="delcon()"  ></td> </form>

      
</tr>
<% } while(rs.next());%>
<tr>
<td colspan=7><hr color="white"></td>
</tr>
<form action="adduser.jsp">
<tr align="center">
<td><input type="text" name="username"></td>
<td><input type="text" name="truename"></td>
<td><input type="text" name="password"></td>
<td><input type="radio" name="priv" value="2" checked></td>
<td><input type="radio" name="priv" value="1" ></td>
<td colspan="2">
<Input type="submit" value="添加">
</td>
</tr>
</form>
</table>
<%
}
} else {
out.println("对不起,您的权限不足!<br>");
out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
}
%></center>
</Body>
</html>

解决方案 »

  1.   

    你的myform2 根本就没有写document
      myform2.action="moduser.jsp";
                myform2.submit(); 
    标准的写法
    应该是document.all.myform2才对
      

  2.   

    document.myform2 也行但是我们公司不提倡使用
      

  3.   

    没有这样用过 都是
     myform2.action="moduser.jsp";
                myform2.submit(); 
    这样用的
      

  4.   

    写成document.myform2 也不行啊.我都试过许多写法.都不行的.小狗狗.为什么你们公司不提但是使用这方法?我查了JSP的参考书.没发现这种写法.但要怎么实现确定功能.大家有其他方法吗?