How to get setTimeout function in webflow form submission

Post author
allinweb dave

Hi all,
On the profile page, after entering the details and clicking the submit button, it redirects to the people list page where the profile items are displayed.

However, the page transitions too quickly, and the profile data doesn't appear until the page is reloaded. So, what I want is, when the submit button is clicked, instead of immediately redirecting to the next page, I'd like it to wait for approximately 3-5 seconds before redirecting.

Can I get the JavaScript source code for this? Thank you.

Comments

5 comments

  • Comment author
    Niket Kumar
    • Edited

    Hey there allinweb dave
    I'm not sure what the form IDs and selectors are but you can probably try adding this.

    <!-- Assuming your submit button has id --> 
    <button id="button-id" type="submit" onclick="submitForm()">Submit</button>

    // And the script goes something like this. You can modify the script as per your requirement

    function submitForm() {
      // Simulate an asynchronous action (e.g., submitting data to the server)
        setTimeout(function() {
            // After the delay, redirect to the people list page
          window.location.href = 'url'; // Replace with your actual page URL
        }, 3000); // 3000 milliseconds = 3 seconds

    Let me know if this works with some tweaks and changes. Thanks :D

    0
  • Comment author
    allinweb dave

    Thanks for reply

    Unfortunetly, I can not use 

    onclick="submitForm()

    in submit form beacuse of webflow's form....

    0
  • Comment author
    Niket Kumar

    Hey there allinweb dave
    Yes you can definitely use onClick for your submit button. Here's how.

    1. Delete the existing submit button on your form.
    2. Create an embed code with this this input tag and place it in place of your submit button,
    <input type="submit" onclick="submitForm()" value="Submit"/>

    and in the same embed script you can write the `submitForm()` function.
    Let me know if that clarifies your question. Thanks much.

    0
  • Comment author
    allinweb dave

    Hi Kumar,
    I solved it by applying the embed submit button as you recommended.
    thanks a lot again!

    0
  • Comment author
    Niket Kumar

    Glad I could help! Have a great day.

    0

Please sign in to leave a comment.