Skip Navigation

[Resolved] Default Value Set in View

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

Problem:
How to set the default value for dropdown select added as views filter

Solution:
You can simply add custom javascript/jQuery code to your view's "Search and Pagination" section's JS editor that should set the default option for your view's frontend filter.

You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/default-value-set-in-view/#post-1623721

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/views/adding-custom-javascript-views/

This support ticket is created 4 years, 10 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by celindaS 4 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1621927
Toolset Support Ticket.JPG

Tell us what you are trying to do?
I am trying to create a view with custom search and a pre-selected filter. I have the view with maps and custom search created but when I try adding simple jQuery code to your view's filter section's JS box, I cannot get the custom search to be pre-filtered.

In the attached image, I would like the map and view to be automatically pre-filtered on NICU Level / Level IV.

Is there any documentation that you are following?
I have been reviewing these closed support tickets:
https://toolset.com/forums/topic/how-to-pre-select-views-filter-radio-button/
https://toolset.com/forums/topic/how-to-prefill-default-value-in-dropdown-box/
https://toolset.com/forums/topic/set-default-value-of-a-view-filter-which-is-a-relationship-field/

Is there a similar example that we can see?
Not that I know of...
What is the link to your site?
hidden link

#1622687

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please tell me what JS code you added to your view to make select a default selection?

If you can send me access details I am happy to check that.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1623721

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following JS code to your view's "Search and Pagination" section JS box:

jQuery(document).ready(function($) {

jQuery("select[name^='wpv-wpcf-level'] option[value='4']").attr("selected","selected").trigger("change");

});

Can you please confirm it works as expected.

#1624363

My issue is resolved now. Thank you!