Question: Is there a way to set descriptions to each checkbox option? What I would like is for Option #1 to display and then directly below it a description for it, then Option #2 along with its description.
I have:

```
 $form['field_options'] = array(
                    '#type' => 'checkboxes',
                    '#options' => array(
                        0 => t('Option #1'),
                        1 => t('Option #2')),
                    '#title' => t('Select Options'),
                    '#description' => t('Entering a description here will display below the last item in the array'),
                    '#default_value' => array(0)
            );

```

Also, for some reason `$form_state['values']['field_options']` in function `hook_node_submit()` shows

```
Array
(
    [0] => 0
    [1] => 0
)

```

shouldnt it show what the states of the checkboxes are like this?:

```
Array
(
    [0] => 1
    [1] => 0
)

```

Thanks

Answer: 
1. It starts with adding the following line to your modules .info file
(rename MYMODULE to your module name or the name you want to give to
your javascript file)

scripts[] = MYMODULE.js
2. The next step is to create the MYMODULE.js file. The general
template of the javascript file looks like:

```
  (function ($) {
     Drupal.behaviors.MYMODULE = {
     attach: function (context, settings) {
        // Your javascript code here
    }
  };
}(jQuery));

```
3. You can pass variables from your PHP to your Javascript file by
adding the following code somewhere in your module.

drupal\_add\_js(array('MYMODULE' => array('tax\_rate' => '0.06')), 'setting');

You can now access this variable in your JavaScript:

```
(function ($) {
  Drupal.behaviors.MYMODULE = {
    attach: function (context, settings) {
      // You can access the variable by using Drupal.settings.MYMODULE.tax_rate
      alert(Drupal.settings.MYMODULE.tax_rate);

    }
  };
}(jQuery));

```
To get the path on js file like following: 

```
var path = Drupal.settings.myModule.basepath;

```

First need to initiate add\_drupal\_js() with 'settings' parameter like : 

```
drupal_add_js(array('myModule' => array('basepath' => '<the-path>')), 'setting'); 

```

Example: 

```
drupal_add_js( array( 
   'myModule' => array(
             'basepath' => drupal_get_path('module', 'myModule')
              )
    ), 'setting' 
);

```

Then on any \*.js file you can access this variable as following: 

```
 (function ($) {
      Drupal.behaviors.myModule= {
        attach: function (context, settings) {
          // You can access the variable by using var 
          path = Drupal.settings.myModule.basepath;
          console.log(Drupal.settings.myModule.basepath);

        }
      };
    }(jQuery));

```