function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AichaSFAichaSF 

VisualForce - Search History delete

Hello,
I have a search box in my visualforce page and I want to add a control on the search history. The idea is to automatically delete the search history.
  <input type="text" id="myInput" placeholder="Rechercher" style="margin-bottom : 5px;width:100%"/>

Any help please.
NagendraNagendra (Salesforce Developers) 
Hi Alcha,

Assuming, you have an input text box used to search on the visual force page, and clear all search results using a command button. 

I have tested the same in my org and it's working fine.

Following technique with an action-support worked. I rerender the page block.

Visual Force Page:
<apex:pageBlock title="Please Search and Select a Source Report" id="pbBlock" >
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputPanel layout="block" Rendered="true" id="panelId">
                        <apex:inputText value="{!ReportSearchString}" />
                        <apex:commandButton value="Search" action="{!searchReports}" reRender="ReportSearchResults, "/> &nbsp;&nbsp; 
                        <apex:commandButton value="Back" action="{!BackToCreateFeedPage}"/>&nbsp;
                        <apex:outputPanel style="padding:4.5px;" styleClass="btn" >
                            Reset
                            <apex:actionSupport event="onclick" action="{!reset}" rerender="pbBlock" />
                        </apex:outputPanel>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>
                <!-- <apex:commandButton value="Back" action="{!BackToCreateFeedPage}"/> -->
            </apex:pageBlockSection>
Method:
public pageReference reset()    {
      showTable = false;
      this.ReportSearchString = '';
      return null;    }
Hope this helps.

Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra

 
AichaSFAichaSF
Thank your for you're response, 

In visualforce page I have this script related to inputtext

<script>
        $(document).ready(function(){
            console.log("in");
            $("#myInput").on("keyup", function() {
          
                var value = $(this).val().toLowerCase();
                                
                $("[id$='partTable'] tr").filter(function() {
                    $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
                });
                
            });
        });
    </script>    

I need not save any search in this inputtext.
Have you any ideas.