Skip Navigation

[Resolved] Use the default value on a select to reset all filters

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 3 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#1622259

I have created a woocommerce product search.
I use dropdowns of different taxonomies to filter my Products.

I would like to reset all filters when selecting the default option of my first select field.

#1622849

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

I am not sure to fully understand your question. I might need to know what the first filter is? And maybe how your view is created?

But I'll still give it a try. I think this may be possible with custom Javascript code, added to the view, that will listen for events changes on the first filter and check its value, if it is equal to the first value, it may trigger a reset of the form and set the value for the filter(because it will be empty after reset).
hidden link

A code similar to:

jQuery(function($){
  $('select[name=category]').on('change', function(){   // you may need to adapt "select[name=category]" depending on your form
      var select = $(this);          // get a jquery object around the select field
      var value = select.val();  // get the value of the select filter
      if (value == 'first-select-value') { // check the value against our desired value
        select.parent('form').trigger('reset'); // reset the form
        select.val(value);   // set the value again for the filter as it will be reset
      }
  })
})

If you have any doubts about this solution, please allow me temporary access to take a closer look at your form. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.