Serialize un-successful elements

Serialize un-successful elements

Hi,

I need to create a query string for all un-checked checkboxes. There is the very convenient serialize() method for checked=true but I can't find a means of getting all the values for check boxes that are un-checked. I have tried serializeArray but that returns an empty array.

The context for this is that I have a select/deselect all link on a page. I need all the element values to be POSTed to the server so that the user's selection can be stored server-side in-between page requests. If they de-select all I need to remove those items from the users session.

Here my effort. Can anyone suggest a means of collect and serializing all un-checked checkboxes?
Thanks in advance.
TomRed.

  1. function make_all_toggler(path,val) {
        return function() {
            jQuery(path).each(
                function(){
                    jQuery(this).attr('checked',val);

                }
            );






  2. // send_selection wants a serialised list, true/false and the form's id
            if (val == true ) {
                send_selection_to server( jQuery(path).serialize(), val, jQuery(document.forms[1]).attr('id') );
            }
            else {
                console.log(jQuery(path).serializeArray());
                send_selection_to server( jQuery(path).serializeArray(), val, jQuery(document.forms[1]).attr('id') );
            }
            return false;
        };
    }












  3. function make_select_all_links_work() {
        jQuery("form#myform a.select_all").click(
            make_all_toggler("form#myform input:checkbox",true)
        );


  4.     jQuery("form#myform a.deselect_all").click(
            make_all_toggler("form#myform input:checkbox",false)
        );
    }