View Full Version : How to create a clear button using Jquery for refine search

July 29, 2012, 04:07 PM
I been doing this whole night and I still can't get this RESET button ... anyone?

How to create a Clear button to clear all the fields so that user can do a fresh refine search?

=========== refine_search.tpl ==================

<td style="padding-{$text_dir_rev}: 10px;"><input class="search_field_item button" type="submit" name="search" value="{$lang.search}" /></td>
<td><input type="button" class="button" value="Clear Form" id="reset_filter_button" /></td>

<script type="text/javascript">



$("#filters select option[value='']").attr('selected', true);
$("#filters input[type=text]").val('');
$("#Category_ID option").show();


July 30, 2012, 06:43 AM
Hello Desmond,

Would you please create a new button with id="reset_filter_button" and insert next code in file.

<script type="text/javascript">
$(".refine").find("input[type='text'], input[type='hidden']").each(function(){

July 31, 2012, 05:32 AM
I have tested it does not work well

Step 1:
Search field A
Press "Search

Step 2 :
Search result listing appear for field A

Step 3:
Press "Reset Search"
reset ... field A disappear on Refine search box

Step 4 :
Change field B
Press "Search"

Step 5:
Search result listing appear for field B
But on the refine search box, it show field A not B.

It did not clear the previous session completely. You can test it on my site to confirm my findings

July 31, 2012, 08:22 AM
Hello Desmond Lim,

Yes you are right. I found problem. Please go to ftp:includes>>controllers>>listing_type.inc.php
find code:

/* emulation */
if ( $_SESSION[$listing_type_key .'_post'] && $_REQUEST['action'] != 'search' )

and replace to:

/* emulation */
if ( $_SESSION[$listing_type_key .'_post'] && $_REQUEST['action'] != 'search' && !$_POST )

August 2, 2012, 02:32 AM
Hi Viktor
Thanks for the fix, it is working now