在JSP中定义了多个按扭(button),如何实现点击不同的按扭转向不同的页面,同时不同的按扭也要传递不同的隐藏值到相应的页面。

解决方案 »

  1.   

    将按钮的type设置为button,然后在onclick事件中对不同按钮设置所在form的action为不同值就行了!
      

  2.   

    <form action="a.jsp" target="_blank">
      <input type="hidden" name="hidden1" value="">
      <input type="submit" value="button1">
    </form>
    <form action="b.jsp" target="_blank">
      <input type="hidden" name="hidden2" value="">
      <input type="submit" value="button2">
    </form>
    <form action="c.jsp" target="_blank">
      <input type="hidden" name="hidden3" value="">
      <input type="submit" value="button3">
    </form>
    这样不就可以了
      

  3.   

    就是我想在一个<form>表单中实现哦。就是大家能不能给偶一个示例程序啊。先谢谢大家了。
      

  4.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script>
    function selSub(target){
    document.form1.action = target;
    document.form1.submit();
    }
    </script>
    <body>
    <form name="form1" method="post" action="">
      <p>
        <input type="text" name="textfield1">
      </p>
      <p> 
        <input type="text" name="textfield2">
      </p>
      <p> 
        <input type="text" name="textfield3">
      </p>
      <p> 
        <input type="button" name="Submit" value="submit1" onClick="selSub('b.jsp');">
        <input type="button" name="Submit" value="submit2" onClick="selSub('c.jsp');">
        <input type="button" name="Submit" value="submit3" onClick="selSub('d.jsp');">
      </p>
    </form>
    </body>
    </html>测试过。能用 ^_^