- 浏览: 1005550 次
- 性别:
- 来自: 天津
文章分类
- 全部博客 (445)
- Java (22)
- J2EE (18)
- Flex (102)
- Flex-blazeds (1)
- Flex-FABridge (2)
- Flex4 (3)
- CheckStyle (2)
- PowerDesigner (0)
- POI (2)
- Java2Word (2)
- 杂项 (15)
- 日记 (3)
- 数据库-oracle (41)
- 数据库-SQLServer (7)
- 中间件 (1)
- 英语 (8)
- C# (43)
- ASP.net (72)
- ASP.net MVC (28)
- 微软-Entity Framework (19)
- JavaScript (22)
- JQuery (31)
- EasyUI (3)
- VS2010 (4)
- CVS (1)
- Tomcat (3)
- Linux (1)
- 遗留问题 (1)
- iphone (1)
- MAC (0)
- 系统 (2)
- Web Service (4)
- Cache Manager (1)
- PMP (1)
- WCF (10)
- BootstrapJs (1)
- Web API (6)
- Go语言 (0)
- 网络协议 (2)
- Redis (10)
- RabbitMQ (10)
- Git (3)
- Kafka (5)
- ELK (5)
- Nginx (3)
- 测试 (2)
最新评论
-
ygm0720:
Table行拖拽自己实现 -
程乐平:
Flex4开发视频教程(27集)下载http://bbs.it ...
Flex4教程 -
liuweihug:
Jquery+asp.net 后台数据传到前台js进行解析的办 ...
AJAX $.toJSON的用法或把数组转换成json类型 -
weilikk:
谢谢谢谢!!
javascript IE下不能用 trim函数解决方法 -
gxz1989611:
vigiles 写道请问楼主:[Fault] exceptio ...
blazeds推送技术至Flex
In this post we will see the use of jQuery in finding the count of checked and unchecked items from a list of checkboxes along with their count. This is also one of the common problems I faced and looked into how to use not selector and also found that count comes as not expected many a times so whats the reason behind that.
Let’s take a look at a generic example page where we have a list of checkboxes inside a table enclosed in a div (you can use any other scenario like a div having a list of checkbox elements only or a combination of checkboxes and other elements in it).
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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"> <head runat="server"> <title></title> <script src="jquery-1.2.6.js" type="text/javascript"></script> <% if (false) { %> <script src="jquery-1.2.6-vsdoc.js" type="text/javascript"></script> <% }%> <script type="text/javascript"> //Write your code when Document is loaded $(document).ready(function() { $("#testChk").click(function() { alert($("#testCheck :checked").size()); //function to print the value of each checked checkboxes $("#testCheck :checked").each(function() { alert("value = " + $(this).val()); }); $("#tblSub").click(function() { //show count of all not checked checkboxes only alert($("#testTB :input:not(:checked)").size()); //show count of all not checked elements alert($("#testTB :not(:checked)").size()); //function to print the value of each not checked checkboxes $("#testTB :input:not(:checked)").each(function() { alert("value = " + $(this).val()); }); }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div id="testCheck"> <input type="checkbox" checked="checked" value="1" /> <input type="checkbox" checked="checked" value="2" /> <input type="checkbox" checked="checked" value="3" /> <input type="checkbox" checked="checked" value="4" /> <input type="checkbox" checked="checked" value="5" /> <input type="checkbox" checked="checked" value="6" /> <input type="checkbox" checked="checked" value="7" /> <input type="checkbox" checked="checked" value="8" /> </div> <input id="testChk" type="button" value="Submit" /> <table id="testTB"> <thead> <tr> <th>test</th> <th>chk boxes</th> </tr> </thead> <tbody> <tr><td>test</td><td><input type="checkbox" checked="checked" value="1" /></td></tr> <tr><td>test</td><td><input type="checkbox" checked="checked" value="2" /></td></tr> <tr><td>test</td><td><input type="checkbox" checked="checked" value="3" /></td></tr> <tr><td>test</td><td><input type="checkbox" checked="checked" value="4" /></td></tr> <tr><td>test</td><td><input type="checkbox" checked="checked" value="5" /></td></tr> <tr><td>test</td><td><input type="checkbox" checked="checked" value="6" /></td></tr> </tbody> </table> <input id="tblSub" type="button" value="Submit" /> </div> </form> </body> </html>
Since everything is present in UI so I am not giving the code behind as it would be default without any changes to verify how the above is working.
Here are few lines to take a look upon:
//show count of all not checked checkboxes only
1) alert($(“#testTB :input:not(:checked)”).size());
//show count of all not checked elements
2) alert($(“#testTB :not(:checked)”).size());
In the first one we get the count of all non checked checkboxes only because it uses an addition filter of ‘input’ tag type which is how checkboxes get rendered in html. In case we dont use it as in 2) example then we get all the elements inside div testTB which dont have checked attribute so it return all the tr, td etc elements along with input elements thereby increasing the count of return set.
This is a simple example but would help you in case you are trying to find the non cheched elements and getting unexpected count. The reason there would be that all the checkboxes are not inside one container and hence you would have to use the input tag type. Also you might have to consider addition filtering in case the same container contains other input elements as then not will filter those also in result set causing unexpected count. Som the gist is that either you do the wrapping in such a way that these checkboxes are clubbed together or else you need to use additional filter to find the right result set.
Hope this helps!
发表评论
-
js插件库系列导航
2016-06-02 13:41 550此系列为了建立一个有用的js插件和解决方案库,希望对您有 ... -
js Tree - 树形菜单插件
2016-06-02 13:41 1307js Tree - 树形菜单 ... -
easyui input 取值 赋值
2016-05-13 15:49 907$("#userdlg_useraccount& ... -
Jquery easyUI dialog的close和destroy
2016-05-13 15:48 4339之前在用easyUI的时候遇到一个问题,一直困扰着我。 ... -
jquery-validation 使用
2012-11-06 10:19 5704一、用前必备 官方 ... -
jQuery blockUI插件在ajax提交的时候的用法(block不起作用)
2012-10-23 10:36 5695在开发过程中出现一个问题,就是在IE7,8,9 ,Chrome ... -
AJAX $.toJSON的用法或把数组转换成json类型
2012-09-27 15:35 201801. html页面全部代码 <html> ... -
JQuery dialog弹出对话框解决Asp.net服务器控件无法执行后台代码的方法
2012-09-07 16:55 5464搜索相关问题发现,其中主要问题是出在:JQuery会把Dial ... -
jquery dialog 详解
2012-09-07 16:49 12276还是先看例子吧。另外如果要拖动、改变dialog的大小的话 ... -
jquery操作dropdownlist和radiobuttonlist
2012-08-13 19:08 3032jquery获取ASP.NET服务器端控件dropdownli ... -
JS中showModalDialog 详细使用
2012-04-11 16:51 1152基本介绍: ... -
Window_Open详解
2012-04-11 16:51 930一、window.open()支持环境: Jav ... -
DIV中的image控件,放大,缩小,还原,拖拽
2012-02-10 11:21 5269<!DOCTYPE html PUBLIC " ... -
控制 iframe 内图片放大缩小
2012-02-09 09:09 4011index.asp 页面 <html> & ... -
Jquery框架
2011-11-15 15:52 14011. DWZ 官方网址:http://code. ... -
MVC 分页 JQuery Pager
2011-11-07 13:00 3153导入的包 <script type=" ... -
Jquery与.net MVC结合,通过Ajax
2011-10-14 09:55 2604在工作中做了这么一个东西。 Html端: @using T ... -
jQuery插件ASP.NET应用之AjaxUpload
2011-10-14 09:49 2322本次使用AJAXUPLOAD做为上传客户端无刷上传插件,其最新 ... -
Radio Button and CheckBox在FireFox中刷新自动改变选中项
2011-08-29 12:54 2752今天开发过程中出现了这样一个问题,我选中radio butto ... -
jQuery Supertextarea Plugin
2011-08-18 11:46 1242http://truthanduntruth.com/deve ...
相关推荐
NULL 博文链接:https://caerun.iteye.com/blog/726904
C++ and the Perils of Double-Checked Locking 关于单例模式C++实现的一些问题
C++ and the Perils of Double Checked Locking.zip
本文实例讲述了jQuery中:checked选择器用法。分享给大家供大家参考。具体分析如下: 此选择器能够选取所有选中的复选框或单选按钮。 语法结构: 代码如下:$(“:checked”) 此选择器可以和其他选择器配合使用,比如...
Get row and column index of a GridView Cell Playing with GridView Remove rows from GridView using jQuery Remove GridView columns using jQuery Drag and Drop GridView rows using jQuery Highlight...
• If the LVS_EX_CHECKBOXES style has been applied and a selected item will be checked/unchecked, all other selected items will be checked/unchecked, too. • If the LVS_EX_LABELTIP style has been ...
checked 和 unchecked关键字用来限定检查或者不检查数学运算溢出的;如果使用了checked发生数学运算溢出时会抛出OverflowException;如果使用了unchecked则不会检查溢出,算错了也不会报错。1. 一段编译没通过的代码...
+ When the list of items for droped down filter list is formed, the current filter takes in account (Only when grid is conneccted to TMemTableEh). + Global variable DBGridEhShowInTitleFilterBox ...
• Chapter 21: The Singleton Pattern and the Double-Checked Locking Pattern • Chapter 22: The Object Pool Pattern • Chapter 23: The Factory Method Pattern • Chapter 24: Summary of Factories (no ...
checked 关键字用于对整型算术运算和转换显式启用溢出检查。
The Lancaster Corpus of Mandarin Chinese (LCMC) is designed as a Chinese match for the FLOB and FROWN corpora for modern British and American English. The corpus is suitable for use in both ...
QCheckBox::indicator:checked QCheckBox 选中状态下的指示器。 QCheckBox::indicator:unchecked QCheckBox 未选中状态下的指示器。 QCheckBox::indicator:indeterminate QCheckBox 不定状态下的指示器(部分选中)...
在做角色权限,通过tree控件展示权限列表的时候,用:default-checked-keys绑定数据,这个属性不能实现双向绑定,只能用于初始化选择状态。如果想双向绑定只能使用组件的方法setCurrentKey来实现。想直接绑定数据来的...
主要介绍了通过实例了解checked和unchecked异常,Java异常分为两种类型,checked异常和unchecked异常,另一种叫法是异常和错误。下面小编就带大家来一起学习一下吧
Then all you have to do is click on the "Remove" (or "List Files") button, and wait until the end of the process. Close IntraWeb Bundled Removal Tool and install a new IntraWeb version. Further ...
2、checkbox里的onchange或onclick方法里用jquery的attr方法获取checked是看得到的checked属性的值与它是否给钩上没有关系 3、使用document.getElementById(“checkbox_id”).checked获取的值与是否钩上一至,即与...
Item 15: Minimize the accessibility of classes and members Item 16: In public classes, use accessor methods, not public fields Item 17: Minimize mutability Item 18: Favor composition over inheritance ...
Checked Items - menu items can support checked and unchecked states thus indicating to end-users if an option is been enabled. (Screenshot) Radio Group Items - DevExpress Silverlight Menu controls ...