Jump to content
  • 0
Ed727

Auto-submit form only on initial load

Question

Hello - I have a search form and a results list on the same page, per this approach: https://howto.caspio.com/tech-tips-and-articles/tech-parameters/add-a-search-interface-to-results-sets-page/

The search form is a submission form which passes parameters to a results list.  Both are embedded in the same web page.

When the web page loads I'd like the search form to auto-submit based on some default values, so that a list of results is generated.   Otherwise it just shows "No records found" until the user submits the form.

I see Caspio provided an auto-submit javascript solution below.  However, since the submission form reloads after each search, the below creates an infinite loop.

Does anyone have a simple solution so that the search form auto-submits ONLY when the user first visits the web page?

Thank you.

 

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @Ed727,

I assume that you have both Datapages deployed on a web-page with an embed method.

You can use a JS which clicks on Submit button if my assumption is correct.

Here a a code which you can use on web-page:

<script>

function submit () {

document.querySelector("input[id*='Submit']").click();

}    
    
setTimeout(submit, 5000); 
    
</script>

Hope this helps.

Regards,

vitalikssssss

Share this post


Link to post
Share on other sites
  • 0

That's fantastic, thank you!

I dropped the code into the footer and I also decreased the timing from 5000 to 500 to reduce the delay before it ran; and it runs great!

 

Share this post


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