I'm expanding further on this question.
I currently have an asp hyperlink for Select All
(NumberOfCheckBoxes
) which works, but what I'm looking to do is add another link, possibly just a standard HTML hyperlink for Uncheck Selected
(NumberOfCheckedBoxes
) and update the value of NumberOfCheckedBoxes
as checkboxes are ticked, without reloading the page.
I have javascript already for unchecking them, but not counting them and printing it to screen.
I'm not sure if JQuery is the way to go with this or just standard Javascript.
Thanks in advance for any help.
I'm expanding further on this question.
I currently have an asp.net hyperlink for Select All
(NumberOfCheckBoxes
) which works, but what I'm looking to do is add another link, possibly just a standard HTML hyperlink for Uncheck Selected
(NumberOfCheckedBoxes
) and update the value of NumberOfCheckedBoxes
as checkboxes are ticked, without reloading the page.
I have javascript already for unchecking them, but not counting them and printing it to screen.
I'm not sure if JQuery is the way to go with this or just standard Javascript.
Thanks in advance for any help.
Share Improve this question edited May 23, 2017 at 11:51 CommunityBot 11 silver badge asked Aug 20, 2009 at 8:17 LiamGuLiamGu 5,34812 gold badges50 silver badges68 bronze badges2 Answers
Reset to default 12With jQuery you can:
$("input:checkbox:checked").length;
Try this:
var inputElems = document.getElementsByTagName("input"),
count = 0;
for (var i=0; i<inputElems.length; i++) {
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
count++;
}
}