Jump to content
  • 0

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


roattw

Question

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>

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

Here is the sequence of events:

Search box set to not show results under:

search1.jpg.d110be9a8a7a46e5bcc5045a864ef112.jpg

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

search3.thumb.jpg.951c7cdfd0aaf3ea41bf3cb115270011.jpg

 

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

search2.jpg.ae56d5df2d0d21e4e5e8498cdeb014cd.jpg

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.

search5.thumb.jpg.fe614b859e70a3d8efbb09010ab6273f.jpg

 

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

search6.thumb.jpg.93818c98b5a8d82581e1c675e0985985.jpg

Thank you!!!!!

search4.jpg

search6.jpg

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.

image.png.c57e12b0aa1091b3f52f9887fa005b42.png

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

image.thumb.png.5a544c2b8aeff7ff05b8dee0e72d67ee.png

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

image.thumb.png.41c72a5696c887dbe0bf8f6b7b57faee.png

 

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:

<style>
.cbBackButtonContainer{
display: none !important;
}
</style>

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.

Guest
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.

Loading...
×
×
  • Create New...