Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PREVENT FORM LOADING #16

Closed
cliffordaddison opened this issue Oct 5, 2022 · 0 comments
Closed

PREVENT FORM LOADING #16

cliffordaddison opened this issue Oct 5, 2022 · 0 comments

Comments

@cliffordaddison
Copy link

The function below prevents my form from loading once I hit the submit button however, the text in my input are not submitted to my google sheet.

Once I comment this function out, the form is submitted but it loads to my webapp. How do I resolve this?

window.addEventListener("load", function() {
const form = document.getElementById('bay-form');
form.addEventListener("submit", function(e) {
e.preventDefault();
const data = new FormData(form);
const action = e.target.action;
fetch(action, {
method: 'POST',
body: data,
})
.then(() => {
alert("Success!");
})
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant