This topic is locked
[SOLVED]

 Clear search field

1/5/2021 9:19:42 AM
PHPRunner General questions
L
leteck author

I have a search but I'm hiding data until search and with that option I cannot clear the search field after a search. How can I add a button to clear the search field

DealerModulesDevClub member 1/5/2021

I might be setting up the search differently than you are but on my apps when I do a search, it automatically puts in a new button with either an "X" or a button that says "Show All" in it.

It is right after the word you typed. It only shows up after you typed in your search word(s) and hit enter.
Paul

S
smez 1/6/2021

My solution to this is to create a custom button with a "Clear search" label and the following "Client Before" code:

var currentPath = window.location.pathname;

window.location.replace(currentPath + "?a=showall");

return false;


Since the ID for my custom button is "custom_button9", I then added the following PHP code to the "Before display" event on the list page:

if( SearchClause::getSearchObject($table)->isUsedSrch() )

$pageObject->showItem("custom_button9");

else

$pageObject->hideItem("custom_button9");



This php code ensures that my "Clear search" button will only be displayed if a search has been applied.

L
leteck author 1/11/2021