I have a search and some filters on a drupal 7 site. If I search a term, for example "stuff", and there are 30 results, I can click a checkbox filter (let's call it FilterA) on the side and narrow my results down. But now if I type "things" in the search bar and submit it, FilterA is still clicked when the results come up. I need for all the filters to be unchecked when I perform a new search. I've gone through I feel every setting in the view and all the search and filter settings and still nothing. Thank you for any help you can provide.


To fix this I created a new block and inserted this code:

    //unchecks all checkboxes
    function clearCheckBoxes(){
        var uncheck=document.getElementsByTagName('input');
                    for(var i=0;i<uncheck.length;i++){
    //this function makes sure that new searches aren't hindered by filters set for previous searches.
        if(typeof(Storage) !== "undefined"){
            //retrieve what's in search box and remove whitespace
            var currentsearch = document.getElementById("searchbar").value;
            currentsearch = currentsearch.trim();       
            //if search box has a value that differs from the session storage search value then filter checkboxes are unchecked and url is sanitized of categories
            if (currentsearch.length > 0){
                if (sessionStorage.getItem("squery")) {
                    let oldsearch = sessionStorage.getItem("squery");
                    if(currentsearch !== oldsearch){
                        location.pathname = 'simplepathname';   
                // set session storage search value equal to current value
                sessionStorage.setItem("squery", currentsearch);

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.