Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.91 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jquery multiple checkboxes - selector problem [SOLVED]
  2. <input type="checkbox" name="first_category[]" value="1" />
  3. <input type="checkbox" name="first_category[]" value="2" />
  4. <input type="checkbox" name="second_category[]" value="3" />
  5. <input type="checkbox" name="second_category[]" value="4" />
  6.        
  7. var test = Array();
  8.  
  9. $('input[name=first_category[]]:checked').each(function()
  10. {
  11.     test.push($(this).val());
  12. });
  13.  
  14. alert(test);
  15.        
  16. <input type="checkbox" name="first_category[]" value="1" />
  17. <input type="checkbox" name="first_category[]" value="2" />
  18. <input type="checkbox" name="second_category[]" value="3" />
  19. <input type="checkbox" name="second_category[]" value="4" />
  20. <br/>
  21. <input type="button" value="check" id="btnCheck"/>
  22.  
  23. $("#btnCheck").live('click', function() {
  24.     var test = [];
  25.     $("input[name='first_category[]']:checked").each(function() {
  26.         test.push($(this).val());
  27.     });
  28.     alert(test);
  29. });