How to show a table depending on a drop down selection? Initially there is only drop down menu in the form, when a selection is made I want to display a table in the same form.

$form['blood_group'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('Blood Group'), 
    '#options' =&gt; array(
        'a+' =&gt; 'a +ve',
        'b+' =&gt; 'b +ve',
        'ab+' =&gt; 'ab +ve',
        'o+' =&gt; 'o +ve',
        ), 
    '#required' =&gt; TRUE,
);


suppose if the user selects a+ i have to show the table containing names of all the people with the same blood group.
You can take a look at the #ajax property of the Drupal Form API.

Here is a good start :

$form['blood_group_wrapper']['tables'] = array(
  '#prefix' =&gt; '&lt;div id="table-wrapper"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
);

$form['blood_group_wrapper']['blood_group'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; t('Blood Group'), 
  '#options' =&gt; array(
      'a+' =&gt; 'a +ve',
      'b+' =&gt; 'b +ve',
      'ab+' =&gt; 'ab +ve',
      'o+' =&gt; 'o +ve',
      ), 
  '#required' =&gt; TRUE,
  '#ajax' =&gt; array(
    'callback' =&gt; 'ajax_show_table',
    'wrapper' =&gt; 'table-wrapper',
    'method' =&gt; 'replace',
    'effect' =&gt; 'fade',
  ),
);

function ajax_show_table($form, $form_state) {
  $table = '&lt;table&gt;&lt;/table&gt;';
  $form['blood_group_wrapper']['tables']['#markup'] = $table;

  return $form['blood_group_wrapper']['tables'];

}