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: 
First of all you need to call `drupal_add_js()` with a 'settings' parameter. This will inform your Drupal.settings javascript namespace about the settings/variables you need in this file via drupal. Try the following :

Lets suppose you want to call a specific \*.js file on a nodes' view page, call it as :

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

```

This `basepath` is global and you can get it in any \*.js file called at this point. Next, you can use this `basepath` in your \*.js file as :

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

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