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

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s