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));

```
At First you need to have a module or create a module 

See detailed steps below on adding this condition

* Create a folder called 'custom' in `sites/all/modules`
* Create a folder called 'mycustomjs' in above custom folder
* Create a file called 'mycustomjs.info' inside above folder with

below code

```
name = My Custom JS Alters
description = A custom module to interact with JS
core = 7.x
package = Custom

```

Create a file called mycustomjs.module inside 'mycustomjs' folder with
below code

```
<?php

 function mycustomjs_init(){

      global $base_path;
      global $base_url;

     $my_base_path = $GLOBALS['base_url'] . $GLOBALS['base_path'];
    // or $my_base_path = $base_url . $base_path;

       $my_settings = array(
         'basePath' => $base_path,
         'animationEffect' => variable_get('effect', 'none')
       );

      drupal_add_js(array('mycustomjs' => $my_settings), 'setting');

    }
?>

```

For JS side 

```
var basePath = Drupal.settings.mycustomjs.basePath;
var effect = Drupal.settings.mycustomjs.animationEffect;

```

For more information See below 

[Creating Drupal 7.x modules](https://drupal.org/developing/modules/7) 

[Drupal 7 global javascript variables](https://stackoverflow.com/a/14234901/1877909) 

[The Drupal JavaScript API](https://drupal.org/node/304258)

[Drupal Base Url](https://api.drupal.org/api/drupal/developer!globals.php/global/base_url/7) 

[get-complete-base-url-drupal-site](http://data.agaric.com/get-complete-base-url-drupal-site)