javascript的问题,我真的不知道这里是哪里错了,不要说为什么不用另外种方法实现,我只想问下这么实现哪里
错了?各位大侠谢谢了,叩谢!!
<html><script>
function tt(form){
if (form.find.value.length!=0)
{
form.action = "show.jsp";
}
form.submit();
}
</script><head>
<title>查询显示</title>
</head>
<body>
<form name="form3" method="post" action="" target="topFrame" onSubmit="tt(this)">
.
.//省略无关部分
.
<input type="text" name="find" size="12">
<input type="submit" name="Submit" value="提交">
.
.//省略无关部分
.
</form>
</html>当我点提交的时候页面左底下角一闪提示“页面有错误”,也就是脚本有错误,
我把脚本去掉的时候就没有错误提示了,所以可以肯定错误是由脚本引起的。
在文本框find输入字符后点提交不能正确转到show.jsp页面,但是在框架topFrame处
显示了自己页面,就等于直接把页面提交到了topFrame位置,而没有执行脚本(可能是因为脚本错误而没执行)
请各位高手指点下,谢谢了!

解决方案 »

  1.   

    那里<script> 应该换成 <script language=javascrip>也是一样的错
      

  2.   

    有两处错误;
     onsubmit="tt(this)"  onsubmit 全小写<script> 
    正确语法:<script type="text/javascript">
      

  3.   

    <script> 
    function   tt(form){ 
    if   (form.find.value.length!=0) 

    form.action   =   "show.jsp"; 

    form.submit(); 

    </script> 不管那里错了,我教你一个东西,你就不会把function tt(){alert("***");}函数内部的东西都删了,看能不能跳转进去?着种最简单的调试你不会?
    建议你好好学习呵呵
      

  4.   

    问题依旧一样!
    下面是详细代码!,先谢谢楼上的各位,karlpan01你提到的,我按照你的做了,把form.action="show.jsp"; 改成alert("***");后 再此尝试能在表单提交前正确触发alert,然后在topFrame位置显示本身页面。
    <%@ page language="java" pageEncoding="GBK"%>
    <%@page import="logicbean.*,java.util.*"%>
    <%
    request.setCharacterEncoding("GBK");
    response.setCharacterEncoding("GBK");
    String i = null;
    i = new String(request.getParameter("depart").getBytes("ISO8859_1"));
    %>
    <%
    String action = request.getParameter("action");
    if (action != null && action.equals("add")) {
    String[] c = request.getParameterValues("ch");
    if(c==null||c.length==0){}else{
    String tt = "";
    for (int j = 0; j <c.length; j++) {
    tt = tt + c[j]+",";
    }
    session.setAttribute("bb", tt);

    response.sendRedirect("user_list.jsp");
    }
    }
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html><script language=javascript> 
    function s() 

       var a = document.getElementsByTagName("input"); 
       for (var i=0; i<=a.length; i++) {
          if (a[i].type == "checkbox") a[i].checked =!a[i].checked; 
      } 
    }
    </script><script  type="text/javascript"> 
    function tt(form){
    if (form.find.value.length!=0)
    {
    form.action = "show.jsp";
    }
    form.submit();
    }
    </script>
    <head>
    <style type="text/css">
    .
    .//CSS样式
    .
    </style>
    <title>查询显示</title>
    </head> <body>
    <form name="form3" method="post" action="" target="topFrame" onsubmit="tt(this)">
    <input type="hidden" name="action" value="add" /> <table class="tableborder" align="center" cellpadding="4"
    cellspacing="1" width="70%">
    <tr>
    <td width="8%" align="center" class="altbg1" height="10">
    <font color="red">搜索:</font>
    </td>
    <td width="30%" align="left" class="altbg1">
    <input type="text" name="find" size="12">
    <label>
    <input type="submit" name="Submit" value="提交">
    </label>

    </td>
    <td width="15%" align="center" class="altbg1" >

    <label>
       <input type="button" name="Submit2" value="全部">
    </label>

    </td>
    <td width="18%" align="center" class="altbg1">

        <label>
    <input type="submit" name="Submit3" value="加入选定列表" >
        </label>

    </td>
    <td align="center" width="30%" class="altbg1">

    </td>
    </tr>
    <tr class="header"> <td align="center" width="9%">
    <input name="selectAll" type="button" onclick="s()" value="所有"/>
    </td> <td align="center" width="20%">
    姓名
    </td>
    <td align="center" width="15%">
    姓名简拼
    </td> <td align="center" width="26%">
    手机号码
    </td>
    <td align="center" width="30%">
    所属部门
    </td>
    </tr>
    <%
    DAO dao = new DAO();
    List list = new ArrayList();
    temp temp = new temp();
    list = dao.userList(i);
    for (int j = 0; j < list.size(); j++) {
    temp = (temp) list.get(j);
    %>
    <tr>
    <td class="altbg1" align="center">
    <input name="ch" type="checkbox" 
    value="<%=temp.getName()%>" />
    </td>
    <td class="altbg1" align="center">
    <%=temp.getName()%>
    </td>
    <td class="altbg1" align="center" nowrap="nowrap">
    <%=temp.getPinyin()%>
    </td>
    <td class="altbg1" align="center" nowrap="nowrap">
    <%=temp.getPhone()%>
    </td>
    <td class="altbg1" align="center" nowrap="nowrap">
    <%=temp.getDepart()%>
    </td> </tr> <%
    }
    %>

    </table>
            </form> </body></html>