0

I have three check box and one button in a form.name like as selectall , city ,state.if I check selectall button the remaining city and state also getting selected.its work fine.I need to get count of selected check boxes except that selectall . Which means if I select either city or state I need count as 1.if I select city and state I need count as 2.I don't want to count selectall button count???

In my case if I check the selectall button the remaining two check boxes also checked as per requirements.but I need to count the city and state alone except selectall .how to do this???

1
  • you can just count :checked and subtract 1 if selectAll is checked... Commented Nov 22, 2014 at 5:54

2 Answers 2

1

Well with jQuery it's easy. Assuming you can give the "select all" checkbox the "selectall":

var count = $("#YourFormID input[type='checkbox']:checked").not("#selectall").length;

Demo: http://jsfiddle.net/tkevs5q6/

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

$('input[type="checkbox"]').change(function(){
  var count = $('input[type="checkbox"]:not("#chkselectall"):checked').length;
});

Demo:

http://jsfiddle.net/Lbs39h97/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.