I have drupal form with three select box i want to change select box 2nd and 3rd after change value of 1st select box.

ex: i have Three select box

1) Cruise line

2) Destination

3) Ship Id

When user select any value of Cruise line then i want to update value of 2) Destination and 3) Ship id

2nd and 3rd select box value are dependent on 1st select box

your answer really appreciated

Thanks in advance

2 Answers 2


Try one of the following module

Simple hierarchical select

Simple hierarchical select defines a new form widget for taxonomy fields to select a term by "browsing" through the vocabularies hierarchy.

Hierarchical Select

This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.

Or you can also achieve that by writing a custom module :)

  • but its only update one select box. i want to update two select box when value change of first Sep 29, 2014 at 9:28
  • @AjayGadhavana Try out the Conditional Fields module. Sep 29, 2014 at 9:36

Finally I have found answer for updating multiple field after changing values of select box

function callback_function($form, &$form_state)
  $commands = array();
  $commands[] = ajax_command_replace('#element1', drupal_render($form[any form element]));
  $commands[] = ajax_command_replace("#element2", drupal_render($form[any form element]));
  return array('#type' => 'ajax', '#commands' => $commands);

In your ajax callback add ajax_command_replace(). This function have two arguments, first argument is element id (ex: div,span etc that's you want to replace) second argument is HTML or data that's that you want to place at place of element.

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.