I've been trying to get an answer to the following question AJAX dependent select. However I think I'm compounding to many concepts. Perhaps I should first master the FAPI AJAX before building upon it. I can not get the following to work properly. After selecting an option I get the drupal clock like it's going to re-render the text field however nothing happens and the value does not change. Where am I going wrong?

function main_iosupload_form($form, &$form_state) {
//Define SQL Lookup Query
  $sqlplatform = "SELECT vid, name FROM {taxonomy_vocabulary} WHERE vid >= 4";

  $result = db_query($sqlplatform);
  $options = array();
    foreach ($result as $row) {
      $options[$row->vid] = t($row->name);

$form['platform'] = array(
  '#type' => 'select',
  '#title' => t('Select a Platform'),
  '#options' => array(
    0 => t('- Select -')) + $options,
  '#default_value' =>  0,
  '#required' => TRUE,
  '#ajax' => array(
    'callback' => 'ajax_select_callback',
    'wrapper' => 'replace_model_div',
    'effect' => 'fade',

$form['model_wrapper'] = array(
  '#type' => 'textfield',
  '#default_value' => (!empty($form_state['values']['platform']) ? $form_state['values']['platform'] : t("Intial Value")),
  '#prefix' => '<div id="replace_model_div">',
  '#suffix' => '</div>',

return $form;
function ajax_select_callback($form, $form_state) {
  return $form['model_wraper'];

1 Answer 1


Almost a whole week of hitting my head on this. Yeah it helps if in the callback function I call back the correct form name... sigh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.