Jump to content
  • 0

Auto-Submit Search Form When Parameters Received


Question

Is there a way to automatically 'search' if the search form receives a parameter? I would like the search form to act normally most of the time, but, if the search form receives a parameter, I would like it to automatically go to the results page. 

I was thinking of modifying the Auto Submit script with an if/then clause that would check to see if the fields already have a value upon load, and submit if so. But,then I thought it would cause a problem going back to the search form from the results page because the old values are still present when you do that. Sounds like it would create a loop.

I would like to avoid creating an entire new datapage just to have it filter results instead of have a search form. 

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @kpcollier

Then a bit of javascript to check for the parameter.

<script>
  var p = '[@your_parameter]';
  if(p !== '') {
    console.log('parameter present - auto search');
    yourAutoSubmitFunction();
  } else {
    console.log('no parameter - behave normally');
  }
</script>

Pair this with the AutoSubmit described here (and that you mentioned)

 

To prevent a loop, reset Caspio parameters with (cbResetParam=1  on the link back to search.

  • Search form URL: /your-search-page.html?cbResetParam=1

I hope this helps

image.png

Edited by LWSChad
Improved formatting
Link to post
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...