• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

counting checked checkboxes in a table

 
J. Kevin Robbins
Bartender
Pie
Posts: 1793
20
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table displaying multiple rows of data, each row contains a checkbox. I know how to bind to the click event with jQuery, but what I'm struggling with is how to count the number of checkboxes that are checked. If two are already checked and the user tries to check a third, I need to popup a dialog telling them that only two records can be selected and that they must uncheck one before they can check another. I know how to use .dialog, so we don't need to get into the details of that. I just need a little push on iterating over all the checkboxes and determining if they are checked or not.

Be gentle with me, Bear, I'm only on chapter 2 of your book. Javascript and jQuery are very new to me.

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64962
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


(Of course replace myForm with the id of your form element.)
 
J. Kevin Robbins
Bartender
Pie
Posts: 1793
20
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice. A single line of code. jQuery is amazing.

Thank you, very much. And thanks for jqia.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64962
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic