jquery filter .not()

Posted by FFish on Stack Overflow See other posts from Stack Overflow or by FFish
Published on 2010-04-18T14:48:19Z Indexed on 2010/04/18 14:53 UTC
Read the original article Hit count: 388

Filed under:
|
|
|
|

I have a form with image thumbnails to select with checkboxes for downloading. I want an array with the images in jQuery for an Ajax call.

2 questions:
- On the top of the table there is a checkbox to toggle all checkboxes that I want to exclude from the mapping. I had a look at jQuery's .not() but I can't implement it with the :checkbox selector
- is the following example code correct?

$(document).ready(function() {
    $('#myform').submit(function() {
        var images = $("input:checkbox", this).map(function() {
            return $(this).attr("name");
        }).get().join();

        alert(products); // outputs: ",check1,check2,check3"
        return false; // cancel submit action by returning false
    });
}); // end doc ready

HTML:

    <form id="myform" action="" >
    <input type="checkbox" id="toggleCheck" onclick="toggleSelectAll()" checked="checked" ><br />

    <input type="checkbox" name="001.jpg" checked="checked" /><br />
    <input type="checkbox" name="002.jpg" checked="checked" /><br />
    <input type="checkbox" name="003.jpg" checked="checked" /><br />
    <br />
    <input type="submit" value="download" >
</form>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about not