I’m using Zend_Form to output a set group of checkboxes:
<label style='white-space: nowrap;'><input type='checkbox' name='user_group[]' id='user_group-20' value='20'>This Group</label>
With a normal HTTP Post these values are passed as an array, but when I’m somewhat stumped on how to grab all the values using jQuery. I figured I can select the group using:
$('input[@name='user_group[]']').val()
but that just grabs the value of the first checkbox in the list regardless of if it is checked of not. Any ideas?
You could use the checked selector to grab only the selected ones (negating the need to know the count or to iterate over them all yourself):
With those checked items, you can either create a collection of those values or do something to the collection: