Jump to content
  • 0

Reset Parameters using standard 'Search Again' link


kpcollier

Question

I've got a Search and Report datapage embedded on my web page. The search form has an autosubmit function, where if a parameter ([@DateF]) is present, it will 'autosearch'. If there is no parameter, it acts as a normal search form. 

I am trying to find a way to reset the parameters using the standard link to search form. The 'Search Again' button that Caspio provides. I'm trying to use this one because my webpage is separated out by Roles, and multiple Roles use this same page. The URL for these roles are different, so I cannot just put a static href anchor tag. Hence why I am trying to use the standard feature, because this goes straight back to the search form in the same instance. 

We've tried using this, where 'cbSearchAgain' acts as cbResetParam for search buttons (info from support), but my autosubmit function can still find the parameter after trying this out. In turn, I can never get to the search form.

document.addEventListener('DataPageReady', function (event) {

var searches = document.querySelectorAll("a[data-cb-name='SearchAgainButton']");

searches.forEach(function(search){
search.href = search.href.replace('cbSearchAgain=true', 'cbSearchAgain=false');
})
});

Any ideas?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Great find on the cbSearchAgain parameter but I think it only works if the search values are manually typed. For parameters, since it is stored in browser's cache, wouldn't adding cbResetParam=1 work? I guess just add it to the replace function in your script like?: 

 

document.addEventListener('DataPageReady', function (event) {

var searches = document.querySelectorAll("a[data-cb-name='SearchAgainButton']");

searches.forEach(function(search){
search.href = search.href.replace('cbSearchAgain=true', 'cbSearchAgain=false&cbResetParam=1');
})
});
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...