WEB小结(2)——一次提交多个表单
2016-02-02 17:38
411 查看
我们在开发的时候常常需要按一个按钮然后提交多个表单,在这里我在body中设置两个表单,在按表单1的提交按钮时一起提交
表单1和表单2:
test.html:
关键点:
通过表单id获取表单对象,通过onClick事件和submit()函数提交多个表单
表单1和表单2:
test.html:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>用户登录界面</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script type="text/javascript"> function submitit(){ //第一个表单 var tform1= document.getElementById("action1"); //第二个表单 var tform2= document.getElementById("action2"); //提交第一个表单 tform1.submit(); //提交第二个表单 tform2.submit(); } </script> </head> <body> <form id="action1" name="foration1" action="/maven-web/login" method="post" > 用户名:<input type="text" name="userName"/><br/> 密码:<input type="password" name="password"/><br/> <input type="submit" value="提交" onClick="submitit();"/> </form> <form id="action2" name="foration2" action="/maven-web/login2" method="post"> 用户名2:<input type="text" name="userName1"/><br/> 密码2:<input type="password" name="password1"/><br/> <input type="submit" value="提交"/> </form> </body> </html>
关键点:
通过表单id获取表单对象,通过onClick事件和submit()函数提交多个表单
相关文章推荐
- jquery中是否可见
- 商品多属性选择效果
- Oracle数据库查看某天创建的所有表、视图等
- 通过中看不中用的代码分析Ioc容器,依赖注入....
- C#使用ICSharpCode.SharpZipLib.dll压缩多个文件
- PictureChooser
- hibernate开发环境搭建
- 旋转木马轮播图:实用大气的轮播效果
- MySQL安装配置
- centos下搭建docker私有仓库
- Android中Gson解析详解json2
- UESTC 1269 ZhangYu Speech
- Android常用工具类
- 暴力法解凸包
- python 多线程笔记(2)-- 锁
- 6. Java 加解密技术系列之 3DES
- tomcat内存配置优化
- Web服务器的工作原理
- 通过char **指针改变char*指针的指向
- PLSQL Developer备份恢复oracle数据