Clear search form from external button

Hi,

I am trying to create some extra buttons for automated searches and things on the list view page and for them to work, I have to clear the search form first and then search.

However when I use the clear form function with ‘this.form’ it obviously doesn’t work because it’s outside of the form area.

How can I create a button that clears the search form no matter where the button is placed on the page?
Thanks.

The ListView clear button has an id of search_form_clear. You can use plain javascript to get this button and click it or use JQuery:

$('#search_form_clear').click();

Thanks,
Jim

Hi,

You can add button and add javascript code as following.

suppose your button has id ClearForm,

$(document).ready(function(){

$(’#ClearForm’).click(function(){

var _form = $(’#search_form’);

SUGAR.searchForm.clear_form(_form);

return false;

});

});

Hope this helps…