http://blog.csdn.net/w709854369/article/details/6261624
不知道大家遇没遇到这种情况,当我们提交一个表单的时候,可能因为相关的参数不同而需提交给不同的action地址。这时我们就可以用JS来实现这种功能。
===============
把相同的内容提交到不同的页面
===============
[javascript] view plaincopy
- <mce:script type="text/javascript"><!--
- function insertStu(){
- document.getElementById(‘myForm‘).action = "ctl.jsp?op=insert";
- document.getElementById("myForm").submit();
- }
- function deleteStu(){
- document.getElementById(‘myForm‘).action = "ctl.jsp?op=delete";
- document.getElementById("myForm").submit();
- }
- function modifyStu(){
- document.getElementById(‘myForm‘).action = "ctl.jsp?op=modify";
- document.getElementById("myForm").submit();
- }
- function selectStu(){
- document.getElementById(‘myForm‘).action = "ctl.jsp?op=select";
- document.getElementById("myForm").submit();
- }
- t;</mce:script>
<form id="myForm" action="" method="post">
<input type="button" name="qurray" value="查询" onclick="selectStu()" />
<input type="button" name="updata" value="修改" onclick="modifyStu()" />
<input type="button" value="添加" onclick="insertStu()" />
<input type="button" name="del" value="删除" onclick="deleteStu()" />
</form>
==========================================================
也可以把js语句直接写在input按钮的 onclick 里:
<form name="form1" action="">
<input type="button" value="action1" onclick="form1.action=‘1‘;form1.submit();">
<input type="button" value="action2" onclick="form1.action=‘2‘;form1.submit();">
</form>