自动全选和自动去除全选
2013-08-07 13:44
127 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@taglib uri="/struts-tags" prefix="s"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <% String app = request.getContextPath(); %> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>发送列表</title> <link rel="stylesheet" type="text/css" href="<%=app %>/css/base.css" /> <script language="javascript"> //复选框全选的方法 function selAll(obj) { var o=document.getElementsByName("che"); for(var i=0;i<o.length;i++) { if(obj.checked==true) o[i].checked=true; else o[i].checked=false; } } //点击取消按钮的方法 function btnCancel() { window.close(); } //得到选中的手机号 function getCellValue() { var all=document.getElementsByName("che"); var len=document.getElementsByName("che").length; var fin=""; var phone=""; for(var i=1;i<len;i++) { if(all[i].checked==true) { var chId=parseInt(all[i].value); var rowNum=chId; var m=document.getElementById("table").rows[rowNum].cells[4].innerHTML; phone=phone+m+","; } } fin=phone.substring(0,phone.length-1); if(fin=="" || fin==null){ alert("您还没有选择客户!"); return; } window.returnValue=fin; window.close(); } //判断是否全部被选中,如果选中全选复选框被选中,反之未被选中 function selFirst() { var o=document.getElementsByName("che"); var count=0; var num=0; for(var i=0;i<o.length-1;i++) { if(o[i+1].checked==true) { count++; } if(o[i+1].checked==false) { num++; } } if(count==o.length-1) { o[0].checked=true; } if(num>0) { if(o[0].checked==true) { o[0].checked=false; } } } </script> </head> <body leftmargin="5" topmargin="5" > <form action="" method="post" target="_self"> <table width="700" border="0" id="table" cellpadding="2" cellspacing="1" class="maintable" align="center" style="margin-top:8px" > <tr class="tr1"> <td height="24" colspan="7" align="center" > <strong>发送列表</strong> </tr> <tr align="center" class="tr2" > <td><input name="che" type="checkbox" value="1" onclick="selAll(this)"></td> <td width="127">编号</td> <td width="81">客户名称</td> <td width="81">身份证</td> <td width="81">手机号</td> <td width="119">卡号</td> <td width="85">业务状态</td> </tr> <s:set var="num" value="2"></s:set> <s:iterator id="customer" value="customerInfos"> <tr class="tr2" align="center" > <td><input name="che" type="checkbox" onclick="selFirst()" value="<s:property value="#num"/>"/></td> <td><s:property value="#customer.customerID"/></td> <td><s:property value="#customer.userName"/></td> <td><s:property value="#customer.cardID"/></td> <td><s:property value="#customer.phone"/></td> <td><s:property value="#customer.cardNum"/></td> <td><s:property value="#customer.isState"/></td> </tr> <s:set var="num" value="#num+1"></s:set> </s:iterator> <tr align="center"> <td colspan="7" > <input name="" type="button" onclick="getCellValue()" value="确定" style="height:25px;width:70px;"> <input name="" type="button" value="取消" onclick="btnCancel()" style="height:25px;width:70px;"> </td> </tr> </table> </form> </body> </html>
相关文章推荐
- 去除 struts2 标签中的自动生成的布局样式table/tr/td+ 全选 反选
- jquery全选,全不选,单个取消选中全选自动去除, 单个全部选中全选自动勾选
- 百度ueditor富文本编辑器使用 以及去除自动保存
- html input text 得到焦点后自动全选
- 如何让select 多选自动默认为全选?
- python 自动去除空行的实例
- 关于inline-block,间隙距离去除,以及div自动换行,高度等问题的一个demo
- html 日期、全选全部选、添加自动行列
- [Android]去除EditText自动获得的焦点,解决软键盘弹出问题
- sqlserver数据库 表中字段值有空格,如何去除空格(例如char (5) 存入数据不足5位时sqlserver会自动补空格)
- 去除JSP页面自动生成的空行
- IntelliJ IDEA 去除IDE自动的参数名 提示功能
- 去除input的自动填充色
- TextBox获取输入焦点时自动全选的实现方法
- 去除SortedList的自动排序功能
- 去除EditPlus自动备份功能. bak (转)
- eclipse如何设置自动去除多余引入的类?
- 用source insight宏自动加入或去除C注释
- 去除 struts2 标签中的自动生成的布局样式