created element with ajax ,not act autocomplete i have a select option value , in change create a text field with auto complete feature,
every thing is ok , but autocomplelete of this element not work!!!

part of my code    

        $form['azlocation']=array(
            '#type' =&gt; 'select',
            '#title' =&gt; 'location',
            '#options' =&gt; array(1,2,3),
            '#default_value' =&gt; 1,
            '#description' =&gt; t('select your news location.'),
            '#ajax' =&gt; array(
                    'event' =&gt; 'change',
                    'callback' =&gt; 'country_select_f',
                    //'path' =&gt;'roadtonowhere',
                    'wrapper' =&gt; 'city-term',
                    'method' =&gt; 'replace',
                    'effect' =&gt; 'fade',
            ),
            );
    $form['field_terms_city']= array(
            '#markup' =&gt; '&lt;div id="city-term"&gt;&lt;/div&gt;');



    function country_select_f(&amp;$form, $form_state){
$form['city_list_item2'] =array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('select city (optional)'),
        '#autocomplete_path' =&gt; 'user/autocomplete',
        '#weight' =&gt; -1,
        '#attributes' =&gt; array('id' =&gt;'city-term-select'),
);


where is the problem?
Try this.

$form['azlocation'] = array( 
'#type' =&gt; 'select',
'#title' =&gt; 'location',
'#options' =&gt; array(1, 2, 3),
'#default_value' =&gt; 1,
'#description' =&gt; t('select your news location.'),
'#ajax' =&gt; array(
  'event' =&gt; 'change',
  'callback' =&gt; 'country_select_f',
  //'path' =&gt;'roadtonowhere',
  'wrapper' =&gt; 'city-term',
  'method' =&gt; 'replace',
  'effect' =&gt; 'fade',
 ),
 );
 $form['field_terms_city'] = array(
 '#type' =&gt; 'textfield',
 '#title' =&gt; t('select city (optional)'),
 '#prefix' =&gt; '&lt;div id="city-term"&gt;',
 '#suffix' =&gt; '&lt;/div&gt;',
 );
 return $form;
}
function country_select_f($form, $form_state){
   $form['field_terms_city']['#autocomplete_path'] = 'user/autocomplete';
   return $form['field_terms_city'];
}