Put your checkboxes inside some container to distinguish them from
check all checkbox. Secondly, amend your ajax post function so it
takes a set of id's. The rest is pretty clear...

----
Read jQuery HowTo Resource  -  http://jquery-howto.blogspot.com



On Tue, Feb 24, 2009 at 3:47 PM, heohni
<heidi.anselstet...@consultingteam.de> wrote:
>
> Hi,
>
> I have a list of search results. Each result has its own checkbox to
> select a product.
> Each checked product ID gets saved to the session via Ajax. Fine so
> far, it works already.
>
> But I also have a "check / uncheck all" checkbox.
> That means, when I check all, I need to send all displayed (not all
> results in general, just the displayed products (5 per page)) product
> id's to the session.
>
> And there my problem starts.
> How can I get all checkboxes on the current page? And how can I
> exclude the "check all" checkbox? And how can I call for each found
> checkbox my ajax function to add/delete the id?
>
>
> Thanks a lot for any help!!!
>
>
> Currently my code looks like this:
>
> html:
> <input type="checkbox" name="paradigm[]" value="{$value.ver_id}" {if
> $smarty.session.checked_products[$value.ver_id] == $value.ver_id}
> checked="checked"{/if} />
>
> jquery:
> $(document).ready(function() {
>        // Change colour of selected row
>        $("input:checkbox").click(function(){
>        var checked_status = this.checked;
>        //alert(checked_status);
>
>        var ver_id = $(this).val();
>        //alert(ver_id);
>
>
>                if(checked_status == true) {
>                        //alert('checked');
>                $(this).parents("tr:eq(0)").addClass('highlighttr');
>                //add functionality to handle a check
>
>                        // save checked products to session
>                        $.ajax({
>                                type: "POST",
>                                url: 
> "/ajax_add_selected_product_to_session.php",
>                                data: "ver_id=" +ver_id,
>                                success: function(msg){
>                                        /* add here what to do on success */
>                                        //alert(msg);
>                                }
>                        });
>
>        }else{
>                        //alert('unchecked');
>                $(this).parents("tr:eq(0)").removeClass('highlighttr');
>                //add functionality to handle an uncheck
>
>                        // delete checked products from session
>                        $.ajax({
>                                type: "POST",
>                                url: 
> "/ajax_unselected_products_from_session.php",
>                                data: "ver_id=" +ver_id,
>                                success: function(msg){
>                                        /* add here what to do on success */
>                                        //alert(msg);
>                                }
>                        });
>        }
>        });
> });
>
>

Reply via email to