日期:2014-05-19  浏览次数:20717 次

a标签如何把表单提交给stuts
我有个如下的登陆页面
HTML code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>湖北经济学院在线作业系统</title>    
  </head>
      <SCRIPT>
         function userLogin()
         {    
             var radio=document.all.user;   
              var value=null;   
              if(radio.length){   
                for(var i=0;i<radio.length;i++){   
                      if(radio[i].checked){
                          value=radio[i].value;break;
                      }   
                }  
              }else if(radio.checked){
                  value=radio.value;   
              }   
            if(value == '1'){
                document.myform.action="LoginAction.do?method=Login&user=stu";
            }else if(value == '2'){
                document.myform.action="LoginAction.do?method=Login&user=tea"
            }else{
                document.myform.action="LoginAction.do?method=Login&user=adm";
             }
             document.myform.submit();
         }
             
     </SCRIPT>
  <form name = "myform" method = post>
  <body>
    <p><center><font size=15>湖北经济学院在线作业系统</font></center>
       <br><br><br>
       <center><table>
           <tr><td>帐号:</td><td><input type = text value = "04064261132" name ="username"><td></tr>
           <tr><td>密码:</td><td><input type = text value ="12345" name ="password"><td></tr>
           <tr><td></table>
    <table><tr><td><input type = "button" value="登陆" onClick="userLogin()"></td>
            <td><input type = "button" value="返回"></td></tr></table>
      <table>    <tr><td>学生:<input type = "radio" name="user" value=1 checked></td>
               <td>老师:<input type = "radio"  name="user" value=2></td>
               <td>管理员:<input type = "radio"  name="user" value=3></td></tr>     <table>
               <a href="LoginAction.do?method=Login&user=tea">aaa</a>
   <center>
  </body>
  </form>
</html>



为什么我点按钮可以提交给action,点<a href="LoginAction.do?method=Login&user=tea">aaa</a>这个链接就不行啊,
有谁知道我这个链接那里写错了吗

我不要在a标签里面写onClick事件

------解决方案--------------------
如果不用onClick事件 估计只有神仙可以把表单传过去
没有提交事件是不会提交表单的
你为什么要这样做