+3  A: 
  1. An onclick event won't trigger when you programmaticaly change the checked status of a checkbox. You can send a different AJAX request when a user clicks the check all / uncheckall link, without worrying about the click events you attached to individual checkboxes.
  2. This is the tradeoff when using a request per click. Alternatively use a "Save" button that saves the entire form.
  3. Use event delegation - attach one onclick event to the entire container that holds all the checkboxes, and check the target of the event to see if a checkbox was clicked. Also, personally I would avoid showing 500 different options on the same page. If absolutely necessary to have so many options, break them down into several zones / pages.

For a user leaving the page you can use the onbeforeonload event, however if the browser crashes or otherwise exits ungracefully it will not be caught. Use it depending on how critical is it to be able to capture user changes.

Eran Galperin
Yeah, I don't like 500 per page. The default is 30, but people often want to see more so they can compare visually. Also before this functionality, they would need to check very large quantities to perform actions on all of them.
Darryl Hein