使用form里面的button跳转到其他页面

来源:互联网 发布:塔吉克斯坦 知乎 编辑:程序博客网 时间:2024/05/18 02:34

在使用表单的时候,有时需要从一个页面跳转到多个不同的页面。

比如:想要从1.jsp跳转到2.jsp和3.jsp。


我们可以这样写程序:

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>跳转</title><script type="text/javascript">//把表单的action改为2.jspfunction Two() {document.form.action = "2.jsp";document.form.submit();}//把表单的action改为3.jspfunction Three() {document.form.action = "3.jsp";document.form.submit();}</script></head><body><form action="" method="post" name="form"><table width="300" border="1" align="center" bgcolor="#9AD3A4" bordercolor="red"><tr><td align="center" colspan="2" >button跳转</td></tr><tr><td><input type="button" value="跳转到2.jsp" onclick="Two()"      class="botton"/></td><td><input type="button" value="跳转到3.jsp" onclick="Three()"    class="botton"/></td></tr></table></form></body></html>
我们就可以从1.jsp跳转到2.jsp或者是3.jsp从而实现一个页面访问多个页面。

原创粉丝点击