Hello and welcome to our community! Is this your first visit?
Register

Results 1 to 2 of 2
  1. #1
    WTF Groupie Array
    Join Date
    Dec 2007
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can I get an array of the values from the checked checkboxes in a group?

    How can I get an array of the values from the checked checkboxes in a group? I know about .serializeArray(), but that gives me a list of objects with name and value attributes

  2. #2
    WTF Groupie Array
    Join Date
    Oct 2011
    Posts
    287
    Thanks
    0
    Thanked 1 Time in 1 Post


    here's a concept, it might help..

    HTML Code:
    <input type="checkbox" name="field[]" value="1" />
    <input type="checkbox" name="field[]" value="2" />
    <input type="checkbox" name="field[]" value="3" />
    <input type="checkbox" name="field[]" value="4" />
    <input type="checkbox" name="field[]" value="5" />
    
    
    <script type="text/javascript">
    
    var checkedValues = [];
    $("input[type=checkbox]").each(function(idx,element){
     if(element.checked)
       checkedFields.push(element.value);
    });
    
    </script>


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •