display selectable drop down options based on a checkbox selection I am trying to create a form in Drupal. I want to create the following situation: if a  checkbox is selected I want to display a drop down menu. can you please suggest a way to do it.
Programatic way 

  $form['checkbox_form'] = array(
    '#type' =&gt; 'checkbox',
    '#title' =&gt; t('sometitle'),
    '#default_value' =&gt; variable_get('checkbox_form', TRUE),
  );

  $form['selectbox'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('sometitle'),
    '#default_value' =&gt; variable_get('selectbox'),
    '#options' =&gt; array(
          TRUE =&gt; t('Yes'),
          FALSE =&gt; t('No'),
     ),
    '#states' =&gt; array(
      'visible' =&gt; array(
        ':input[name="checkbox_form"]' =&gt; array('checked' =&gt; TRUE),
      ),
    ),
  );


Second form element visible makes the trick.

Module Way

Use Conditional Fields module.


  Conditional Fields allows you to manage sets of dependencies between
  fields. When a field is “dependent”, it will only be available for
  editing and displayed if the state of the “dependee” field matches the
  right condition. When editing a node (or any other entity type that
  supports fields, like users and categories), the dependent fields are
  dynamically modified with the States API. A simple use case would be
  defining a custom “Article teaser" field that is shown only if a "Has
  teaser" checkbox is checked, but much more complex options are
  available.