Blacklight.onLoad(function() {
  $(window).on('load', function(){

    //remove default mast search to fix duplicate IDs
    $(".blacklight-catalog-advanced_search #search-navbar").remove();
    $(".blacklight-trln-advanced_search #search-navbar").remove();
    
    // change adv search scope
  	window.location.href.indexOf('advanced_trln') != -1 ? $('#option_trln').attr('checked',true) : $('#option_catalog').attr('checked',true);
  	
  	$("input[type='radio'][name='option']").change(function() {
        var action = $(this).val();
        $(".advanced").attr("action", "/" + action);
     });

    // fix labeling for fields generated by Chosen jquery library (https://harvesthq.github.io/chosen/)
    $("[id$='_chosen']").each(function() {
      $the_id = $(this).attr('id');
      $aria_label = $(this).attr('id').replace('_chosen', '_label');
      $('#' + $the_id + ' .chosen-search-input').attr('aria-labelledby', $aria_label);
    });

  });
});
Blacklight.onLoad(function() {
  $(window).on('load', function(){

    //remove default mast search to fix duplicate IDs
    $(".blacklight-catalog-advanced_search #search-navbar").remove();
    $(".blacklight-trln-advanced_search #search-navbar").remove();
    
    // change adv search scope
  	$(".blacklight-trln-advanced_search").length > 0 ? $('#option_trln').attr('checked',true) : $('#option_catalog').attr('checked',true);
  	
  	$("input[type='radio'][name='option']").change(function() {
        var action = $(this).val();
        $(".advanced").attr("action", "/" + action);
     });

    // fix labeling for fields generated by Chosen jquery library (https://harvesthq.github.io/chosen/)
    $("[id$='_chosen']").each(function() {
      $the_id = $(this).attr('id');
      $aria_label = $(this).attr('id').replace('_chosen', '_label');
      $('#' + $the_id + ' .chosen-search-input').attr('aria-labelledby', $aria_label);
    });

  });
});
Remove window.location.href in advanced search js
Remove window.location.href in advanced search js
