mercredi 23 novembre 2011

【转】JSP 同一个form,不同的按钮提交到不同的jsp 页面进行处理


问题:在一个JSP页面中需要多个提交按钮,每个按钮点击后需要把同一个form提交到不同的页面进行处理
解决:用JS。
<html>
<head>
<title>一个表单、多个提交按钮、提交到多个不同页面</title>
</head>
<script>
function sm1(){
   document.getElementByIdx("form1").action="1.jsp";
   document.getElementByIdx("form1").submit();
}
function sm2(){
   document.getElementByIdx("form1").action="2.jsp";
   document.getElementByIdx("form1").submit();
}
</script>
<body>
<form action="" method="post" id="form1">
 <input name="mytext" type="text" id="mytext" />
 <input name="bt1" type="button" id="bt1" value="提交到1.jsp" onclick="sm1()" />
 <input name="bt2" type="button" id="bt2" value="提交到2.jsp" onclick="sm2()" />
</form>
</body>
</html>

原文地址:http://blog.sina.com.cn/s/blog_60328aa70100di5a.html