- 浏览: 1024208 次
- 性别:
- 来自: 天津
文章分类
- 全部博客 (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 592此系列为了建立一个有用的js插件和解决方案库,希望对您有 ... -
js Tree - 树形菜单插件
2016-06-02 13:41 1349js Tree - 树形菜单 ... -
easyui input 取值 赋值
2016-05-13 15:49 953$("#userdlg_useraccount& ... -
Jquery easyUI dialog的close和destroy
2016-05-13 15:48 4432之前在用easyUI的时候遇到一个问题,一直困扰着我。 ... -
jquery-validation 使用
2012-11-06 10:19 5755一、用前必备 官方 ... -
jQuery blockUI插件在ajax提交的时候的用法(block不起作用)
2012-10-23 10:36 5735在开发过程中出现一个问题,就是在IE7,8,9 ,Chrome ... -
AJAX $.toJSON的用法或把数组转换成json类型
2012-09-27 15:35 202671. html页面全部代码 <html> ... -
JQuery dialog弹出对话框解决Asp.net服务器控件无法执行后台代码的方法
2012-09-07 16:55 5526搜索相关问题发现,其中主要问题是出在:JQuery会把Dial ... -
jquery dialog 详解
2012-09-07 16:49 12337还是先看例子吧。另外如果要拖动、改变dialog的大小的话 ... -
jquery操作dropdownlist和radiobuttonlist
2012-08-13 19:08 3070jquery获取ASP.NET服务器端控件dropdownli ... -
JS中showModalDialog 详细使用
2012-04-11 16:51 1197基本介绍: ... -
Window_Open详解
2012-04-11 16:51 978一、window.open()支持环境: Jav ... -
DIV中的image控件,放大,缩小,还原,拖拽
2012-02-10 11:21 5305<!DOCTYPE html PUBLIC " ... -
控制 iframe 内图片放大缩小
2012-02-09 09:09 4161index.asp 页面 <html> & ... -
Jquery框架
2011-11-15 15:52 14401. DWZ 官方网址:http://code. ... -
MVC 分页 JQuery Pager
2011-11-07 13:00 3208导入的包 <script type=" ... -
Jquery与.net MVC结合,通过Ajax
2011-10-14 09:55 2645在工作中做了这么一个东西。 Html端: @using T ... -
jQuery插件ASP.NET应用之AjaxUpload
2011-10-14 09:49 2365本次使用AJAXUPLOAD做为上传客户端无刷上传插件,其最新 ... -
Radio Button and CheckBox在FireFox中刷新自动改变选中项
2011-08-29 12:54 2791今天开发过程中出现了这样一个问题,我选中radio butto ... -
jQuery Supertextarea Plugin
2011-08-18 11:46 1285http://truthanduntruth.com/deve ...
相关推荐
本文将深入探讨“Checked”和“Unchecked”异常的区别,以及它们在实际编程中的应用。 Checked异常,也称为编译时异常,是那些在编译阶段必须被处理的异常。如果一个方法可能会抛出Checked异常,那么该方法要么通过...
在介绍双检锁模式(Double-Checked Locking Pattern,DCLP)的C++实现中,Scott Meyers和Andrei Alexandrescu在其2004年的文章中指出,传统的单例模式实现并不具备线程安全性。单例模式是设计模式中经常被提及的一种...
《C++ and the Perils of Double Checked Locking》是一篇探讨C++编程中双重检查锁定(Double-Checked Locking)模式潜在问题的文献。在多线程编程中,双重检查锁定是一种常见的优化策略,旨在减少对同步原语的依赖...
总结一下,`:checked`选择器在jQuery中是一个强大的工具,用于选取和操作用户在网页上选择的复选框和单选按钮。通过与其他选择器的组合,它可以实现复杂的交互逻辑,极大地提升了前端开发的效率和用户体验。在开发...
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. 一段编译没通过的代码...
在C#编程语言中,`checked`和`unchecked`关键字是用来控制整数算术运算和类型转换时是否进行溢出检查的重要工具。了解这两个关键字的用法和含义对于编写安全的代码至关重要,尤其是在处理可能涉及大数值计算或者类型...
+ 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 ...
通过实例了解 Java checked 和 unchecked 异常 Java 异常分为两种类型:checked 异常和 unchecked 异常。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 不定状态下的指示器(部分选中)...
在jQuery中,`attr`和`prop`方法都是用来处理元素属性的,但它们之间存在重要的区别,尤其是在处理像`checked`这样的布尔属性时。`attr`主要用于获取或设置HTML元素的特性(attributes),而`prop`则用于处理元素的...
// log the value of each checked checkbox }); }); ``` 综上所述,jQuery为开发者提供了便利的API来处理checkbox,使得在网页中实现与用户交互变得更加简单和直观。无论是单个checkbox的控制还是批量操作,...
Java中的checked异常和unchecked异常区别详解 Java中的checked异常和unchecked异常是Java语言中两种不同的异常类型,它们之间的区别是很多开发者容易混淆的。下面,我们将详细介绍checked异常和unchecked异常的概念...
但是,在VirtualMode模式下,CheckBoxes的实现却不是那么简单,不能通过设定CheckBoxes = true来实现,还要有特别的处理才能显示选择框. 最近需要用到带CheckBoxes的VirtualMode模式的ListView控件,通过查找资料和研究,...
在网页开发中,jQuery 是一个广泛使用的 JavaScript 库,它简化了 DOM 操作,包括对复选框(checkbox)的处理。本文将深入探讨 jQuery 与 HTML 复选框的 `checked` 属性之间可能遇到的问题及其解决方案。 1. **页面...