一个form表单利用jquey进行多个action传值

  今天在做河北征集系统的时候遇到一个问题:就是需要对报文进行审核,一个form表单需要两个submit来进行操作(审核通过或是不通过)。

  实现如下:

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
   <script type="text/javascript"  src="js/jquery.min.js"></script>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="#" id="loginform" method="post">
<input type="submit" id="ac1">
<input type="submit" id="ac2">
</form>
<script type="text/javascript">
$(document).ready(function(){
    $("#ac1").focus(function(){
        
        $("#loginform").attr('action','MessageServlet?method=Test');
         $("#loginform").submit();

      });
    $("#ac2").focus(function(){
        
        $("#loginform").attr('action','MessageServlet?method=Test2');
         $("#loginform").submit();

      });
    
    
});
</script>

</body>
</html>

 

 

 

     是利用提交按钮的获取焦点事件,在获取到焦点的同时,对form表单的action进行改变。代码中的MessageServlet?method=Test

   是你要提交到的位置。

 

posted on 2020-10-23 22:37  沫戏回首  阅读(174)  评论(0编辑  收藏  举报

导航