Skip Navigation

[Resolved] conditional filter display on parametric search

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by culturaI 6 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#604904

Hello, i can correctly setup a conditional field on cred that appear if another field is chosen. For example:

I have a selectfield "how do you know about us" > agency-university-etc...
If i select "agency" appear another field "what agency" > agency1-agency2-etc
If i select "university" appear another field "what university" > university1-university2-etc
Until now everything ik OK

My question is
There is the possibility to do the same thing on parametric filtering?

I would to select filter "how do you know about us" and another filter appear accordingly

#605075

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

Firstly, please note that you are posting in the Community Forum for users of the free Types plugin. As a Toolset customer you can and should post in the Technical Support forum which we prioritise and where you should receive speedier service.

The same option to conditionally display filters in a custom search form does not exist, I'm afraid.

You can set this up by adding some custom jQuery to your filter controls.

You can use hide() when the page loads to hide the elements you don't want to appear: hidden link

You can check when another field changes using change(): hidden link

You can then show() the elements you want to reveal: hidden link

If you get stuck, let me know.

#606206

Thanks Nigel i understand!
Can you write a brief/simple example of hide jquery in my case?
Then i will write for myself

Thanks!

#606441

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Here is a crude example which simply hides one filter until another filter has been changed. It doesn't test what it has been changed to, for example, simply that something has been selected.

Because I want to hide both the filter itself and its label, I add a class to the wrapper DIV for the form group so that I can target it with jQuery. In my example I add a class of "show-on-change".

Add the following to the custom JS section of the Filter Editor.

( function( $ ) {
	$( document ).ready( function(){
		// Initially hide filter
		$('.show-on-change').hide();

		// Add change listener to other filter
		$('select[name="wpv-wpcf-field-slug"]').change( function(){

			// reveal hidden filter
			$('.show-on-change').show();
		});
	});
})( jQuery );

You will need to use your browser tools to inspect the filter form to identify the selector that can be used to target the change event. In my case it is a select dropdown for a custom field filter.

#608390

Thanks Nigel your code it's working good:

I used:

( function( $ ) {
    $( document ).ready( function(){
        // Initially hide filter
        $('.show-on-change').hide();
 
        // Add change listener to other filter
        $('select[name="wpv-wpcf-come-hai-saputo-dei-corsi"]').change( function(){
 
            // reveal hidden filter
            $('.show-on-change').show();
        });
    });
})( jQuery );

How can i show target field (show-on-change) only if a certain option is selected?

#608404

Ok i managed how to.

Sharing the code for reference:
added class to form1: "quale-agenzia"
added class to form2: "quale-universita"

added code to views

( function( $ ) {
    $( document ).ready( function(){
        // Initially hide filter
        $('.quale-agenzia').hide();
        $('.quale-universita').hide();
 
            
        // Add change listener to other filter
        $('select[name="wpv-wpcf-come-hai-saputo-dei-corsi"]').change( function(){
           if ( $(this).val() == "Agenzie" ) {$('.quale-agenzia').show();$('.quale-universita').hide();}
           if ( $(this).val() == "Università" ) {$('.quale-universita').show();$('.quale-agenzia').hide();}
        });
    });
})( jQuery );

Working good.

Thanks Nigel!

The forum ‘Types Community Support’ is closed to new topics and replies.

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