AJAX callback function never called I'm having trouble with something incredibly simple:
When I select an element in a multiselect-form element, I want a textfield to become enabled. The problem I'm having is that Drupal never manages to get in the callback-function I specified. 

Here I create my multiselect-element:

$form['foocat'] = array(
  '#type' =&gt; 'fieldset', 
  '#title' =&gt; t('Manage subcategories'), 
  '#prefix' =&gt; '&lt;div class="fieldset"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
);
$form['foocat']['subcategories'] = array(
  '#type' =&gt; 'select',
  '#default_value' =&gt; '',
  '#title' =&gt; $foocategory,
  '#options' =&gt; $options,
  '#ajax' =&gt; array(
    'callback' =&gt; 'edit_displayname_callback', 
    'wrapper' =&gt; 'displayname',
  ),
  '#attributes' =&gt; array('id' =&gt; 'foocats',),
  '#prefix' =&gt; '&lt;div class="formselect" id="selectmapcat"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#size' =&gt; 9,
);


A little bit further in the code I create my textfield:

$form['foocat']['subcat_displayname'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Name'),
  '#default_value' =&gt; $entity-&gt;foocategory,
  '#size' =&gt; 25,
  '#maxlength' =&gt; 31,
  '#prefix' =&gt; '&lt;div class="floater" id="displayname"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#disabled' =&gt; TRUE,
);

if(!empty($form_state['subcategories'])) {
  $form['foocat']['subcat_displayname']['#disabled'] = FALSE; 
  //Code for setting the textfield, dependent on what's been selected in the multiselect
}


And this is my callback function:

function edit_displayname_callback($form, &amp;$form_state) {
  watchdog("Test", "Testing callback..", array(), WATCHDOG_ALERT);
  return $form['foocat']['subcat_displayname'];
}


The callback is never even called, and I have no idea why. I use AJAX in another part of the same form, and there it does work, so I'm guessing it's not a form problem.

Can anyone spot the problem?
I guess you are changing the id with '#attributes' =&gt; array('id' =&gt; 'foocats',),
And now the callback is not executed because the id is changed.

if you change your code it will work ( tested this in my own install )

$form['foocat']['subcategories'] = array(
  '#type' =&gt; 'select',
  '#default_value' =&gt; '',
  '#title' =&gt; $foocategory,
  '#options' =&gt; $options,
  '#ajax' =&gt; array(
    'callback' =&gt; 'edit_displayname_callback', 
    'wrapper' =&gt; 'displayname',
  ),
  //'#attributes' =&gt; array('id' =&gt; 'foocats',),
  '#prefix' =&gt; '&lt;div class="formselect MY_SPECIAL_JQUERY_SELECTOR" id="selectmapcat"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#size' =&gt; 9,
);