jamiewilson/form-to-google-sheets

Form Submission Landing "Thank You" Page

n8klayko opened this issue · 1 comments

I am having trouble with getting a landing page working. I have everything working with a custom form and App Scripts, but I need my form submission to redirect users to a specific URL. I saw there link at the bottom of the article and a similar issue listed here, but there is not much description for how to implement this. I know some JS, but I am no expert and could really use a hand figuring this out.

Respectfully,

I figured this out actually. I used the code on the original guide with a modification. In my HTML I added the following:


<script>
window.addEventListener("load", function() {
  const form = document.getElementById('googleform');
  form.addEventListener("submit", function(e) {
    e.preventDefault();
    const data = new FormData(form);
    const action = e.target.action;
    fetch(action, {
      method: 'POST',
      body: data,
    })
    .then(() => {
    window.location.href = 'URL of thank you page';
    })
  });
});
</script>

This fixed the issue and now everything is working correctly.