'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:[1]

  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 (

Solution 2:[2]

Simple in theory. Just store the ids of checked mail in a JavaScript variable and/or cookie, and let them access (via AJAX) as many checkbox lists as they want, before submitting.

Solution 3:[3]

After every time a user selects an email, add the message id to some array in a cookie (you probably want to preform this on-the-fly, with AJAX).

When you load a page with mail, check if the message id has been already checked, and if so, change the default state to checked.

Solution 4:[4]

I Just found the way of doing this using Java Script( no external Program ) and URL Parameters , onclick events , onload events , location.href, using global variable ,read form

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fish-404
Solution 2 Matthew Flaschen
Solution 3 daniel
Solution 4