Add conditional redirect to Views exposed filter (using BEF) I have a view showing a select list of locations. Upon selecting a location the View shows a Google Map with the locations of the current selection.

For certain items in the select list I would like to redirect away from the View to another page.

I have looked at these discussions:

https://www.drupal.org/node/1379492#comment-6273188

How to change programmatically exposed filters in views

But none of them mentions my specific case of conditional redirection.

Any clues very welcome!
A sketch of an idea, for prototyping.
Once this works for you, you could move this javascript code into a render array via form alter. Here are some links for that:


https://api.drupal.org/comment/31448#comment-31448
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#attached


Prototyping: Inside the header area of your view you can insert a js snippet inside of a 'Global: Text area' field (use the full html text format to avoid stripping of html tags):



And here is an example snippet to get you started, I am targeting the node's status exposed filter from my sample view:

&lt;script&gt;
(function($) {
  $( document ).ready(function() {
    $('#edit-status').change(function() {
      switch($(this).val()) {
        case 'optionA':
          window.location = "https://www.drupal.org";            
          break;
        case 'optionB':
        case 'optionC':
          // grouping option together if they have the same target url
          window.location = "https://petrakis.design";            
          break;
        default:
          // default code block, simply exit
      }
    });
  });
})(jQuery);
&lt;/script&gt;


Hope this helped!