form中button未设置type值时点击后提交表单
2015-02-26 22:08
330 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>文件上传</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <script type="text/javascript" src="script/jquery.min.js"></script> <script type="text/javascript"> $(function(){ var i=2; //1.获取#addFile,添加click事件 $("#addFile").click(function(){ //2.生成节点放到#br的前面 /* 节点如下设置: <tr><td>file2:</td><td><input type="file" name="file2"/></td></tr> <tr><td>desc2:</td><td><input type="text" name="desc2"/></td></tr> */ var innerHtml = "<tr><td>file"+i+":</td><td><input type='file' name='file"+i+"'/></td></tr>"+ "<tr><td>desc"+i+":</td><td><input type='text' name='desc"+i+"'/><button type='button'>删除</button></td></tr>"; $("#end").before(innerHtml).prev("tr").find("button").click(function(){ alert(123); $(this).parents("tr").prev("tr").remove(); $(this).parents("tr").remove(); i--; }); i++; }); }); </script> </head> <body> <font color="red">${message }</font> <br/><br/> <form action="uploadServlet" method="post" enctype="multipart/form-data"> <table> <tr> <td>file1:</td> <td><input type="file" name="file1"/></td> </tr> <tr> <td>desc1:</td> <td><input type="text" name="desc1"></td> </tr> <tr id="end"> <td><input type="submit" value="submit"/></td> <td><button id="addFile" type="button">新增一个附件</button></td> </tr> </table> </form> </body> </html>
form表单中<button>未设置type=“button”时,点击该button,表单自动提交到uploadServlet,为<button>添加type属性后该bug不再出现
相关文章推荐
- form表单下的button不设置type会自动提交表单
- 文件上传下载时,在form表单中设置属性enctype=“multipart/form-data”的情况下,如何获取表单提交的值?
- form表单底下的button按钮点击自动提交恶心问题的解决
- form表单重复提交,type=“button”和type=“submit”区别
- 今天遇到一个问题,原来在html的form中如果只有一个type="text"的控件,如果在text中点击回车键,就是自动提交表单!
- button在Firefox下点击提交表单(form)的问题
- 页面点击button自动提交form表单的解决办法
- form 的 encoding设置不当导致在jsp中使用request.getParametre(paraName)无法获取表单提交的值
- form表单的两种提交方式,submit和button的用法
- form表单button自动提交表单处理方法
- form表单重复提交,button问题
- 在一个form用一个SUBMIT(或button)分别提交到两个处理表单页面的代码
- form表单中的submit点击时阻止提交
- form 表单提交的编码设置
- form表单中使button点击后不起作用的方法和原理
- 总结:form中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- 总结:FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- html表单中元素button点击莫名提交的问题
- 关于form表单底下 button自动提交表单的问题
- 总结:form中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别