display 2 tables with checkboxes by ajax button I am altering a form and placing a new 'button' . On the press of the button, using the #ajax property , I want to display 2 separate tables with checkboxes for each row. Each table has separate data.

The 2 tables should be initially hidden and should become visible on button press. How should I proceed with this ??

The table data is fetched from database and some operations are performed on it.. so where should I put this code ? In the callback function ?

Update- I tried to implement this by using tableselect, but the checked boxes aren't returning the values in the $form_state['values']. You can check out the code here 
 or suggest me a simpler interface to implement.
You should not put the table-building code in the ajax callback. Put the code to build the tables into the hook_form_alter() implementation that you are using to add the button. You can use $form_state['triggering_element'] to tell if the button has been pressed, and only execute the query and build the tables if you need to.