Search code examples
javascriptajaxperlcgi

Multiple Page Check Box Handling


In GMail, the mails are listed. When we we have lots of mails (ex:50), we can select and go to next page, select some more mail, and come back to page 1. But whatever mails the user checked will still be checked.

I just want to implement the same operation. How would I do that?

Thanks, Krish

Note: I don't want to use AJAX. I'd rather use Javascript, CGI, PERL, etc.


Solution

    1. <input type="checkbox" onclick="toggleValue(this)"> and in handler check the value and store it in array.

    2. JQuery

    $('input[type=checkbox].mail').click(
        function()
        {
            if (this.checked) $(this).addClass('checked');
            else $(this).removeClass('checked');
        }
    );
    $('input[type=checkbox].mail.checked').each(function_here);
    

    Can have some typos in the second one...

    PS: don't know why, but the code above is not being formatted (