当前页面: 开发资料首页 → JSP 专题 → 请教一下大家
请教一下大家
摘要: 请教一下大家
在JSP中定义了多个按扭(button),如何实现点击不同的按扭转向不同的页面,同时不同的按扭也要传递不同的隐藏值到相应的页面。
用javascript可以办到
将按钮的type设置为button,然后在onclick事件中对不同按钮设置所在form的action为不同值就行了!
<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>
这样不就可以了
就是我想在一个<form>表单中实现哦。
就是大家能不能给偶一个示例程序啊。
先谢谢大家了。
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<head>
无标题文档</head>
<script>
function selSub(target){
document.form1.action = target;
document.form1.submit();
}
</script>
<body>
<form name="form1" method="post" action="">
<input type="text" name="textfield1">
<input type="text" name="textfield2">
<input type="text" name="textfield3">
<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');">
</form>
</body>
测试过。能用 ^_^
谢谢了 我来结贴