Form Redirects with third-party backend

Hello all,

Saw some posts about this before but it isn’t quite what I need.

Looking to redirect a form back to the homepage. However, I know nothing about pulling data from the backend and have resorted to a third-party service to get and send me the form data. However, the service itself redirects the form to a “Thank You” page afterwards in the same tab. I would like to keep using the third-party service, but also redirect the user back to the homepage, whether it be a new tab or same window. Is there a copy/paste html or java script for this? Totally lost. Here’s what the form looks like:

<html>
  <body>
    <form id="example" method="post" action="https://www.formbackend.com/my-own-url">
      <button type="submit" onclick="myfunction()">Please Work</button>
       <script>
         function myFunction() {
        window.location.href="https://thesiteiwanttogoto.com";
        }
     </script>
    </form>
  </body>
</html>

Thank you!

is this a freecodecamp challenge?

Not directly. It’s something that I explored while doing the form course, though. Should this topic be elsewhere?

You cannot use this code in FCC if its not strictly used by the instructions you can explore different code in editors like codepen

I understand. I am using VS Code and trying to figure out what I had asked in the original post about redirecting to a different page after the form submission even though my action destination automatically redirects to where it wants.

Probably because there’s no real destination for the form to be submitted

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.