Skip Navigation

[Resolved] Deselect existing filter values when a new value is chosen

This thread is resolved. Here is a description of the problem and solution.

Problem:
In a Custom Search in a View, using checkboxes, I want all selections to be removed each time a new option is selected, so the search allows only one selection.

Solution:
This is not possible in Toolset out of the box, as it is not how a filter is expected to work.
The common way to achieve a goal like yours is to uncheck/unselect previous sections.

This can also be done with Custom Code (JS), but we cannot provide Custom Code in this forum.

I think the easiest solution is to use a intelligent hint to the user of this search instructing what to do to receive certain results.

Another way is to add JS that unchecks everything when a new box is checked (as example if you use checkboxes for the search).
https://stackoverflow.com/questions/30556100/how-to-uncheck-all-checkboxes-if-one-checkbox-checked

Furthermore it is not the best solution, a Select Field would be better for this task as it allows already just one selection.

Cross field dependance is also not possible, hence, if you need to deselect other fields when a choice is made, custom code is needed as well.

This support ticket is created 6 years, 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by Suzanne Wenger 6 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#590680

I am trying to create multiple filters that are not dependent on each other so each filter will reset the results completely. Normally filters, filter results based on filters which are already selected. Meaning the results keep getting smaller as more filters are applied. However, I need any chosen filters to list results for just that filter and reset other filters back.

I would like to do this dynamically as a user selects a new filter, other filters reset. I don't want to force them to reset the filters every time by clicking a "Clear" button when they want to make a different selection. If I have to do this then I will need to hide all other filters but the chosen one until the Clear button is clicked. I also don't want to have to refresh the page each time, as this created a clunky user experience.

Currently the page is pulling in feeds. Each of these feeds is a url which is kept under a new "Feed" post type. I am trying to allow the user to make selections and based on their selection a feed url is pulled into the view. So, each filter needs to be independent of the other as each filter will pull a different static feed url which can't be filtered anymore.

Perhaps there's a different way to do this that I'm not thinking of. I could probably do it with a many to one post relationship, but the sibling post connections are not available yet.

Here is the page: hidden link

#590784

This is not possible in Toolset out of the box, as it is not how a filter is expected to work.
The common way to achieve a goal like yours is to uncheck/unselect previous sections.

This can also be done with Custom Code (JS), but we cannot provide Custom Code in this forum.

I think the easiest solution is to use a intelligent hint to the user of this search instructing what to do to receive certain results.

Another way is to add JS that unchecks everything when a new box is checked (as example if you use checkboxes for the search).
https://stackoverflow.com/questions/30556100/how-to-uncheck-all-checkboxes-if-one-checkbox-checked

#592120

Thank for the suggestions Beda.

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