Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

We talk about how to generate a taxonomy term selection list in the following post.
Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

So we continue to add the jQuery/Javascript code such that when the term is selected, the browser will open the corresponding term page.

The following piece of jQuery/Javascript is redirect you to the selected term page.

(function ($) {
  $(document).ready(function() {
    if ($('#my-selection-list').length > 0) {
      $("#my-selection-list").change(function() {
        var termId = $("#my-selection-list option:selected").attr('value');
        window.open('/taxonomy/term/' + termId, '_self', false);
      });
    }
  });
})(jQuery);

 

Done =)

Reference: Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

Advertisement

One thought on “Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.