复选框批量处理前端实现
2015-06-11 16:49
316 查看
在项目中,对业务的批量处理是一个非常常见的方式,在具体的业务流畅,一般是以复选框多选进入批量处理的页面
下面就以一个具体实例作为讲解
先从前端开始
具体功能实现参考http://heisetoufa.iteye.com/blog/227350
下面来看表格内容的代码
上面的代码运用了迭代器,拿到的Form是exampleForm,具体的参数listChunk,由于结构的特殊性,需要listChunk.collection来取值,最后面是类型,如果是自定义,则最好添加,下面到了复选框,其中<bean:write name="column property="oid" />就是复选框里面的值,它并显示出来,但会在提交的时候放到Form里面用于action的接收
这里还对onclick进行了指定,一般来讲可以是变色,加粗等,来区分未选择的,网上有很多现成的模板,这里不进行具体讲解
这时,对应的按钮就可以提交了~~~~
例如<a href="XXX.do?state=...onclick="function1(); return false;""/>
这里的function1()主要用于判断是否有选择的复选框,如果没有则给出提示
具体实例如下,这里用function1调用function2函数
function2是一个很重要的模板
下面就以一个具体实例作为讲解
先从前端开始
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="tbDataTable"> <thead> <tr> <td><input type="checkbox" name="chkall" onclick="checkAll(this,'employeeIDs');" /></td> <tb>...</tb> </tr>这是列表的标题,一般这里的复选框主要是用来全选或者全不选
具体功能实现参考http://heisetoufa.iteye.com/blog/227350
下面来看表格内容的代码
<tb:iterate id="column" indexId="index" name="exampleForm" property="listChunk.collection"
type="...common.vo.EmployeeDetailInfoVO"> <tr> <td width="2%"><html:multibox property="employeeIDs" onclick="chkSingle(this,'employeeIDs');"> <bean:write name="column" property="oid" /></html:multibox></td> <tb/>...<td> <pre name="code" class="html"> </tr>...
上面的代码运用了迭代器,拿到的Form是exampleForm,具体的参数listChunk,由于结构的特殊性,需要listChunk.collection来取值,最后面是类型,如果是自定义,则最好添加,下面到了复选框,其中<bean:write name="column property="oid" />就是复选框里面的值,它并显示出来,但会在提交的时候放到Form里面用于action的接收
这里还对onclick进行了指定,一般来讲可以是变色,加粗等,来区分未选择的,网上有很多现成的模板,这里不进行具体讲解
这时,对应的按钮就可以提交了~~~~
例如<a href="XXX.do?state=...onclick="function1(); return false;""/>
这里的function1()主要用于判断是否有选择的复选框,如果没有则给出提示
具体实例如下,这里用function1调用function2函数
function function1(){ if(function2('employeeIDs','请选择要操作的记录')){ document.internalDismissionForm.action = "..."; document.internalDismissionForm.submit() ; } }
function function2(chkName, alertMsg, confirmMsg){ var chkResult = false; var inputs = document.getElementsByTagName('INPUT'); for (i = 0;i<inputs.length;i++){ if (inputs[i].name == chkName){ if (inputs[i].checked){ if(!confirmMsg){ chkResult = true; return chkResult; } return window.confirm(confirmMsg); } } } window.alert(alertMsg); return chkResult; }
function2是一个很重要的模板
相关文章推荐
- 【LeetCode】25.Reverse Nodes in k-Group
- ndis6.0 NetBufferSend
- 【迁移学习】2010-A Survey on Transfer Learning
- TIKZ全局样式设置
- 对js闭包的学习
- html 字符串拼接
- JS常用代码备忘
- HTML5新特性展示利用history.replaceState()修改历史记录
- jquery sticky停靠在右下角的插件 ,jquery pushytip提示框显示插件
- iOS5 strong, weak, unsafe_unretained ARC
- 如何判断浏览器的类型?
- js 身份证号验证
- css中div高度自适应
- React.js 基础入门四--要点总结
- 【前端JS】input textarea 默认文字,点击消失
- 手动触发js事件
- JQuery中$.ajax()方法参数详解
- JQuery学习系列1
- js获取url的参数的正则方式
- 剑指offer-第三章高质量的代码(调整数组顺序使得奇数位于偶数的前面)