The wrapper of Text field is changing after adding a new item in a field collection I face a issue in my code in drupal 7. I alter a field_collection module. I have unlimited field collection (field_smart_objectives) that has two field collections (field_smart_objective_task and field_tms_task). field_tms_task is unlimited and has a select list that fire an ajax callback when the selection change and it will update a text field in field_smart_objective_task. My form as in the image below

This is my code 

function field_collection_form_alter(&amp;$form, &amp;$form_state, $form_id) {   
global $user;

if($form_id == 'employee_performance_node_form') {

$weightCount=0;   
$maxField=0;

 $delta_tn=0;
$delta_tn  =$form['field_smart_objectives']['und']['#max_delta'];

while($maxField&lt;=$delta_tn){
    $delta_tn_ud=0;
    $delta_tn_ud = $form['field_smart_objectives']['und'][$maxField]['field_tms_task']['und']['#max_delta'];
    $delta = 0;
    $Count_progress=0;


    while ($delta &lt;= $delta_tn_ud) {

           $content_type= $form_state['values']['field_smart_objectives']['und'][$maxField]['field_tms_task']['und'][$delta]['field_task_progress']['und'][0]['value'];

          if($content_type == "0")
           {
              $Count_progress= $Count_progress + ( 100 / $delta_tn_ud);
           }           


    $form['field_smart_objectives']['und'][$maxField]['field_tms_task']['und'][$delta]['field_task_progress']['und']['#ajax'] = array(
          'callback' =&gt; '_user_ajax_check',
          'wrapper' =&gt; 'test_entity_callback'.$maxField,
          'method' =&gt; 'replace',
          'effect' =&gt; 'fade',
          'event' =&gt; 'change', 
        );

        $delta++;  
}

           if($delta_tn_ud==0)
          {
           $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und'][0]['field_so_progress']['und'][0]['value']['#value'] = $Count_progress;
         }
         else
        {
            $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und'][0]['field_so_progress']['und'][0]['value']['#value'] =$Count_progress;
        }

    $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und']['#prefix'] = '&lt;div id="test_entity_callback'.$maxField.'"&gt;';
    $form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und']['#suffix'] = '&lt;/div&gt;';

$maxField++;
}

function _user_ajax_check($form, &amp;$form_state) {
 $delta_tn=0; 

  $delta_tn  =$form['field_smart_objectives']['und']['#max_delta'];

  return $form['field_smart_objectives']['und'][$delta_tn]['field_smart_objective_task'];

}


We I change the select value of field_tms_task select list, it update the text field and it works fine. My issue is when I add another field_smart_objectives and try to change the select value of the first field_smart_objectives 

$form['field_smart_objectives']['und'][$maxField]['field_smart_objective_task']['und']['#prefix'] = '&lt;div id="test_entity_callback'.$maxField.'"&gt;';

$maxField should be zero, but it change to 1. Could Anyone tell me why it is happen?

Thank you
I have find a solution. I add this code to ajax function and it solves my issue.

$index=0;
    $index= $form_state['triggering_element']['#field_parents'][2];

  return $form['field_smart_objectives']['und'][$index]['field_smart_objective_task'];


Thank you