<script language="JavaScript">
function Check()


   if(document.form.content.value=="")
   {
    window.alert("请输入您要查询的内容!");
    document.form.content.focus();
 
   }
   else
   {
    form.submit();
   
   }
 }
</script>
<form  method="post" action="servlet/searchStaffServlet" name="form">

<input name="submit" type="button" id="submit" onclick="Check()" value="查询">
点击查询为何不跳转到servlet/searchStaffServlet呢?实在搞不懂啊!

解决方案 »

  1.   

      <script>
     function check(){
    var form = document.forms[0];
    if(form.stm_college.value==""){alert("请填写完整");return false;}
          if(form.stm_department.value==""){alert("请填写完整");return false;}
             if(form.stm_professional.value==""){alert("请填写完整");return false;}
                
        
    else
    {
    form.submit();
    }}
     </script>
     form这么取得试试!
      

  2.   

    window.alert("请输入您要查询的内容!");
    这个对话框还能弹出的来,但是form.submit();就没执行
    不知为何
      

  3.   

    可以这么写吗?楼主这么写的意思是想取到整个form的值?
      

  4.   

    var form = document.forms[0];
      

  5.   


    难道你认为 if 和 else 能全部执行!! 
      

  6.   

    把按钮的type="button"改为type="submit"就能跳转。但是用户无论有没有输入查询的内容,都能跳转。郁闷啊可不可这样:
    function Check()

        
       if(document.form.content.value=="")
       {
        window.alert("请输入您要查询的内容!");
        document.form.content.focus();
     
       }
       else
       {    
               不要submit;//(要能写出这样的语句也行^_^)
               
       }
     }
      

  7.   

    问题解决了,貌似是由于后面少了个/,谢谢各位了!
    <input name="submit" type="button" id="submit" onclick="Check()" value="查询"/>