怎么使这个页面按可选的不同值转向三个不同的相应页面,用javascript会使对文本的输入处理的jsp脚本给忽略了,直接转向页面了,应该怎么使表单提交之前仍然可以处理文本内容?希望给个小小的例子.

解决方案 »

  1.   

    用js不会使对文本的输入处理的jsp脚本给忽略呀
    <script>
    function fff()
    {
    if(选择1)
    {document.form1.action="页面1";}
    if(选择2)
    {document.form1.action="页面2";}
    if(选择3)
    {document.form1.action="页面3";}
    document.form1.submit;
    }
    </script>
    <form name="form1" action="">
    <input type="text" name="t1"/>
    <input type="text" name="t2"/>
    <radio name="ra" value="1">
    <radio name="ra" value="2">
    <radio name="ra" value="3">
    <input typ="button" onclick="fff()"/>
    </form>
      

  2.   

    <script>
        function goto()
      {
        f = document.form1;
       for(c=0;c<f.type.length;c++)
       {
        if(f.type[0].checked&&document.all("name").value!=""&&document.all("name").value!="")
        {
        f.action="../student/student_info.jsp?id="+document.all("id").value;
        }
        if(f.type[1].checked&&document.all("name").value!=""&&document.all("name").value!="")
        {
        f.action="../teacher/teacher_info.jsp";
        }
        if(f.type[2].checked&&document.all("name").value!=""&&document.all("name").value!="")
        {
        f.action="../admin/admin_info.jsp";
        }
        }
       document.form1.submit();
     }
      </script>
     <form  method=post action="" name=form1 >
       <input type=radio value="1" name=type checked>学生
      <input type=radio value="2" name=type >教师
      <input type=radio value="3" name=type >管理员
        <%
        String id="";
       String type=request.getParameter("type");
       String name=request.getParameter("name");
       String password=request.getParameter("password");
       if(name==null||type==null||password==null)
       {}
       else if(name==""||type==""||password=="")   
       {
       %>
      <script>
      alert('输入不能为空');
      </script>
      <% 
      
       }
       else
       {
      
       if(!login.checkLogin())
       {
        out.println("您没有注册或是输入有误");
       }
       else
       {
         id=login.get_IDbyname();
       }
       }
      %>
      <input type=hidden name=id value=<%=id%> />
      <input name=b1 type=submit class=button value="登陆" onClick="goto()"/>&nbsp;
      <input type=reset class=button value="重置"/>
      </form>
    就这些,如果按自己写的方法的话,转向的时候根本不能读,系统没有输出...
      

  3.   

    在这里爆郁闷了.害得我在script那里还加了文本不能空的情况,这根本是不行的,啥都没做就直接转向了,不明白,不明白..