Jump to content
  • 0

Return to results (back) and refresh the search form: My Clear Formcode shows all results under search.



Have a pretty basic directory. Search box begins with NOT showing results under search for. m User types in some letter of last name > autocomplete choices to search last name.  Intial results show an entry with Details page enabled.  Detailsa page has a Back button (Update hidden).  Hoping to get a complete refresh of that search page with back.  But going back from details page  to search using code below shows that first  result as it should.  But hitting Clear Form clears the form, but it also shows ALL the results, essentially ignoring my setting to start without showing results under the search form.

I used this tested code from forums for the clear form:

<button type="button" onclick="resetForm()">Clear Form</button>

function resetForm() {
    var myForm = document.querySelector('form[action*="[@cbAppKey]"]').querySelectorAll('input:not([type=submit]):not([type=hidden]), textarea, select');
    myForm.forEach(function(elem) {
    var searchBtn = document.querySelector('.cbSearchButton').click();

Here is the sequence of events:

Search box set to not show results under:


Search takes you to that entry with option for more Details:



Details page with a BACK button option. Update button hidden.


Back goes to initial search result. But Clear Form doesnt start me back at search box wiht no data under it.  Instead it shows new search box with all the data under it, ignoring the setting to not show data under search.



In a perfect world the Back would take me back to empty search like it started:


Thank you!!!!!



Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

Hi @roattw,

I can suggest you to configure your Results DataPage instead of creating a script for it.

1. You'll have to Select Results on a new page.


2. Enable link to search form, so you can still go back to your search form when you are in your results page.


3. On your Details Page options, enable:

  • link to results page to go back to your list of results
  • link to search form to go back to your search page with empty search criteria



To add, in your details page if you click on the button back you will be taken back to the results page. If you want to retain the back button then I suggest disabling the link to results page check box since it is the same function. 

I hope this helps you.

Link to comment
Share on other sites

  • 0

Hi @roattw,

You can also create a custom Back button. Hide the original one, and create a new button with a function that will go back to the initial form.

Add Header/ Footer and disable HTML editor for both elements.

In the Header, you can paste this style to hide the Back Button container:

display: none !important;

In the Footer, use this code to create a custom button:

<button class="cbBackButton" onclick="window.location.href='DATAPAGE_REPORT_URL';">Back</button>


Hope this helps! :) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...