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);
I'm also using Relevanssi.
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.
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>
Never mind, I've fixed it. Thank you very much.
OK, feel free to create new ticket for other new questions.