首页 > 其他 > 详细

一个Form多个提交动作Submit的解决方法

时间:2014-08-14 11:06:28      阅读:287      评论:0      收藏:0      [点我收藏+]

在开发工作共我们往往会遇到一个表单需要包含多个action不同的提交动作,这时候就不能在使用submit按钮来进行提交了,下面提供通过js来实现这一功能的方法

1
2
3
4
5
6
7
8
     
< form name = "demo" method = "post" >
<!--YOUR DATA AREA-->
< input type = "button" value = "添加" onclick = "addAction()" >
< input type = "button" value = "删除" onclick = "deleteAction()" >
< input type = "button" value = "保存" onclick = "saveAction()" >
< input type = "button" value = "查询" onclick = "searchAction()" >
</ form >
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script type= "text/javascript" >
function addAction(){
     document.demo.action= "your add method url" ;
     document.demo.submit();
}
  
function deleteAction(){
     document.demo.action= "your delete method url" ;
     document.demo.submit();
}
  
function saveAction(){
     document.demo.action= "your add save url" ;
     document.demo.submit();
}
  
function searchAction(){
     document.demo.action= "your serach method url" ;
     document.demo.submit();
}
</script>

form表单一定要添加上name属性,以通过document定位访问表单,不要写action属性了


一个Form多个提交动作Submit的解决方法,布布扣,bubuko.com

一个Form多个提交动作Submit的解决方法

原文:http://my.oschina.net/530520/blog/300985

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!