How to synchronize two check boxes values, upon change? In my module, I have created a simple form with a single checkbox (A) and a submit button.
I also have a checkbox (B) boolean that i added in the user profile. 
Now I would like to:


write a submit function that would update checkbox (B) with the status of checkbox (A).
Get rid of the submit button, and have Checkbox B updated automatically  upon change of checkbox (A) status. 


I am trying to achieve an email notification on comments system as I described here in a previous post: How to add a checkbox form to a panel?

Thanks,

baba
I got it working this way:

/**                                                                                                                                                                 
 * Implements hook_block_info                                                                                                                                       
 */
 function mymodule_block_info() {

  $blocks['block_notify'] = array(
                           'info' =&gt; t('Notify me'),
                           'cache' =&gt; DRUPAL_NO_CACHE,
                           );

   return $blocks;
}

/**                                                                                                                                                                   
 * Implements  hook_block_view                                                                                                                                                      
 */
 mymodule_block_view($delta = '') {

 $block = array();
 switch ($delta) {
               case 'block_notify':                                                                                     
                 $block['content'] =  drupal_get_form('mymodule_example_form');                                                                                                                                 
                 break;                                                                                                                                         

              }
  return $block;
}


function mymodule_example_form($form, &amp;$form_state) {

 global $user;
 user_full = user_load($user-&gt;uid);
 $val = $user_full-&gt;field_user_message_notification['und'][0]['value'];

 $form['form_notify'] = array(
                         '#type' =&gt; 'checkbox',
                         '#default_value' =&gt; $val,
                         '#title' =&gt; t('Notify me by email when I receive a new message'),
                         //'#description' =&gt; t("Check this option to be notified by email when you receive a new message"),                                       
                         );

drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule_request.js', 'file');
global $user;


return $form;
}


function mymodule_example_form_submit($form, &amp;$form_state) {
// Submission logic.                                                                                                                                                
 global $user;
 $user_full = user_load($user-&gt;uid);
 $edit = (array) $user_full;
 $edit['field_user_message_notification']['und'][0]['value'] = $form_state['values']['form_notify'] ;
 user_save($user_full, $edit);

 }


Then to trigger form submit on checkbox change I just added the follwing javascript in mymodule_request.js

jQuery(document).ready(

function ($)
{
 jQuery.noConflict();

 $checkBox = $("#edit-form-notify");

 if( $checkBox.length != 0)
 {
    $checkBox.click(
        function(){
            //        alert('hello');                                                                                                                             
            this.form.submit();
            }
          );

 }
});


I can now just select the "Notify me" block in my panel by " add content" in panels.