Ajax callback on select box change event not working on second time I am building a form with form API in a custom module. Certain fields should be populated based on the selected value of a dropdown. 

User will select the pre-entered profiles, based on which other fields should be populated.

I have used ajax callback on select box, it works fine for the first time. But not working on next time.

function multi_step_user_info_form($form, &amp;$form_state) {
$form['user_data_form']['reference_number_ajax'] = array(
'#type' =&gt; 'select',
'#title' =&gt; 'Select a Patient', 
'#ajax' =&gt; array(
        'callback' =&gt; 'ref_number_dropdown_callback',
        'wrapper' =&gt; 'ref_number_list',
        'event' =&gt; 'change',
        'method' =&gt; 'replace',
        'effect' =&gt; 'fade',
        ),  
'#attributes' =&gt; array('class'=&gt;array('dynamic-select')),
'#default_value' =&gt; isset($values['reference_number_ajax']) ? $values['reference_number_ajax'] : NULL,  
'#prefix'=&gt;'&lt;div class="col-md-12"&gt;', 
'#field_suffix'=&gt;'&lt;/div&gt;');  

$form['user_data_form']['patient_name'] = array('#type' =&gt; 'textfield',
'#title' =&gt; 'Patient Name','#value' =&gt; $patient_name, '#default_value' =&gt; isset($values['patient_name']) ? $values['patient_name'] : NULL, 
'#prefix'=&gt;'&lt;div id="ref_number_list"&gt;&lt;div class="col-md-12"&gt;',
'#field_suffix'=&gt;'' 
 ); return $form; } 

function ref_number_dropdown_callback($form, $form_state) {     
    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'node')
      -&gt;entityCondition('bundle', 'query')
      -&gt;propertyCondition('status', NODE_PUBLISHED)
      -&gt;fieldCondition('field_reference_number', 'value', $form_state['values']['reference_number_ajax'], '=')
      -&gt;range(0, 1);
    $result = $query-&gt;execute();
    $nid ='';
    if (isset($result['node'])) {
       $nid = $nid = current($result['node'])-&gt;nid;
       $node = node_load($nid);
    }
  //  $form_state['rebuild'] = TRUE;
  // THESE TWO VALUES SHOULD BE POPULATED ON AJAX CALLBACK //
    $form['user_data_form']['patient_name']['#value'] = $node-&gt;field_patientname[$node-&gt;language][0]['value'];
    $form['user_data_form']['age']['#value']          = $node-&gt;field_age[$node-&gt;language][0]['value'];
    $elements = array($form['user_data_form']['patient_name'],$form['user_data_form']['age']);
    return $elements;
  }
You are using wrong notation for form elements, instead of field_suffix you should use "suffix" tag, as drupal is not able to track your closing tag, for a form element.

function demo_pane_form($form, &amp;$form_state) {

 $options= array(1=&gt;1, 2=&gt;2, 3=&gt;3, 4=&gt;4, 5=&gt;5);

 $form['user_data_form']['reference_number_ajax'] = array(   
  '#type' =&gt;'select', 
  '#title' =&gt; 'Select a Patient',
  '#ajax' =&gt; array(
     'callback' =&gt; 'demo_pane_dropdown_callback',
     'wrapper' =&gt; 'ref_number_list',
     'event' =&gt; 'change',
     'method' =&gt; 'replace',
     'effect' =&gt; 'fade',
   ),   
   '#attributes' =&gt; array(
     'class'=&gt;array('dynamic-select')
   ),  
   '#default_value' =&gt; 1,  
   '#options' =&gt; $options,   
   '#prefix'=&gt;'&lt;div class="col-md-12"&gt;',  
   '#suffix'=&gt;'&lt;/div&gt;' 
 );

 $form['user_data_form']['patient_name'] = array(   
  '#type' =&gt; 'textfield',
  '#title' =&gt; 'Patient Name', 
  '#value' =&gt; 1,  
  '#prefix'=&gt;'&lt;div id="ref_number_list"&gt;&lt;div class="col-md-12"&gt;',  
  '#suffix'=&gt;'&lt;/div&gt;&lt;/div&gt;',
 );

 return $form;

 }

 function demo_pane_dropdown_callback($form, $form_state) {

   $form['user_data_form']['patient_name']['#value'] =
   $form_state['values']['reference_number_ajax'];  
   $form['user_data_form']['age']['#value']          =
   $form_state['values']['reference_number_ajax'];      
   $elements =  array(
     $form['user_data_form']['patient_name'],
     $form['user_data_form']['age'],
   );

  return $elements; 
 }