I have two different taxonomies Taxonomy 1:


Taxonomy 2:

-Russian Open

I have linked Jazz, Rock to music and Fifa, Russian Open to football by term-reference field.

I have content type event, having term-reference to both Category and Sub-category. I want drop-down for sub-category should be populated after selection of Category. Eg. if we select music as category then in sub-category only jazz and rock should be shown.


I think you will have to go for some custom code if you want to use seperate taxonomy vocabularies.

An easier way would be to have all terms in the same hierarchical vocabulary and use Hierarchical Select to create the "populate dropdown"-feature.


Use Hierarchical Select, where you can display category and subcategory in a tree structure. Then use JavaScript to handle the drop down menu. You can get the taxonomy id of parent from the first drop down using jQuery. Then create an Ajax request to get all the child terms. taxonomy_get_children(); function can be used to find all child terms.

You can refer the following code to get better understanding.

(function ($) {
 Drupal.behaviors.custom_filter = {
  attach: function (context) {
    $('#selelctid1').change(function() {
      var id = $(this).val();
        $.ajax({ url: Drupal.settings.basePath + 'yourmenu/' + id,
          success : function(msg) {

Then create a new menu under hook_menu

function mymodule_menu() {
  $items = array();
  $items['yourmenu/%'] = array(
    'page callback' => 'mymodule_get_child_terms',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
return $items;

Create callback function

function mymodule_get_child_terms() {
  $tid = arg(1);
  $taxonomy = taxonomy_term_load($tid);
  $vid = $taxonomy->vid;
  $children = taxonomy_get_children($tid, $vid);
  print '<option value="All">- Any -</option>';
  foreach ($children as $key => $value) {
    print '<option value="' . $value->tid . '">' . $value->name . '</option>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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