Skip Navigation

[Resolved] Reset/clear button doesn't clear field values, does not reset to null

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

Our next available supporter will start replying to tickets in about 0.67 hours from now. Thank you for your understanding.

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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1980291
Screen Shot 2021-03-09 at 4.37.14 PM.png

Reset/clear button does not clear field values inside search form and reset them to null. The "Clear" button does nothing. Can't figure it out. Thank
you!

Shortcode is in content template. This is my view code:

[wpv-filter-start hide="false"]
[wpv-filter-controls]

<div class="form-group-container">
<div class="form-group">

<label for="wpv-region">[wpml-string context="wpv-views"]WHERE ARE YOU?[/wpml-string]</label>
<div class="clear-button">
<button type="reset" value="reset" id="clear">Clear</button>
</div>
[wpv-control-post-taxonomy taxonomy="region" type="select" default_label=" Choose Region " url_param="wpv-region"]
</div>

<div class="form-group">
<label for="wpv-town">[wpml-string context="wpv-views"]TOWN[/wpml-string]</label>
<div class="clear-button">
<button type="reset" value="reset" id="clear">Clear</button>
</div>
[wpv-control-post-taxonomy taxonomy="town" type="select" default_label="-- Choose Town --" url_param="wpv-town"]
</div>

<div class="form-group">
<label for="wpv-restaurant-type">[wpml-string context="wpv-views"]FOOD TYPE[/wpml-string]</label>
<div class="clear-button">
<button type="reset" value="reset" id="clear">Clear</button>
</div>
[wpv-control-post-taxonomy taxonomy="restaurant-type" type="select" default_label=" Choose Food " url_param="wpv-restaurant-type"]
</div>
[wpv-filter-end]
</div>

I've also got js in the css of the loop:

(function( $ ) {
// javascript code here. i.e.: $(document).ready( function(){} );
$('#clear').click(function(e){
var form_id = $(this).parent('form').attr('id');
form_id = '#' + form_id;
$('input[type="radio"], input[type="checkbox"]', form_id).removeAttr('checked'); // radio and checkboxes
$('select option',form_id).removeAttr('selected'); // select
$('input[type="text"]',form_id).removeAttr('value'); // single line text
$('textarea',form_id).empty(); // multiple lines field
});
})(jQuery);

#1980313

I'm also using Relevanssi.

#1980455

Hello,

I assume it is a custom search form of post view, please try the reset button shortcode [wpv-filter-reset], see our document:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-filter-reset
Adds a clear or reset button to a Custom search form.

#1981247
Screen Shot 2021-03-10 at 12.57.22 PM.png

Great, thanks Luo. But now I need CSS help. I'm getting this (shortcode set to button on left, 'CLEAR' appears only on hover and is not formatted).

Using:

<div class="form-group-container">
<div class="form-group">

<label for="wpv-region">[wpml-string context="wpv-views"]WHERE ARE YOU?[/wpml-string]</label>

<div class="clear-button">
[wpv-filter-reset reset_label="Clear" class="clear-button"]
</div>

[wpv-control-post-taxonomy taxonomy="region" type="select" default_label=" Choose Region " url_param="wpv-region"]
</div>

#1981325

Never mind, I've fixed it. Thank you very much.

#1981543

OK, feel free to create new ticket for other new questions.