Created
October 18, 2017 16:16
-
-
Save jamiewilson/c29186b87c76d7ba740bb7eeb0604138 to your computer and use it in GitHub Desktop.
Multiple Forms Submit to Google Sheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="first-form"> | |
<input name="email" type="email" placeholder="Email" required> | |
<button type="submit">Send</button> | |
</form> | |
<form name="second-form"> | |
<input name="email" type="email" placeholder="Email" required> | |
<button type="submit">Send</button> | |
</form> | |
<script> | |
const firstFormScriptURL = '<FIRST FORM SCRIPT URL>' | |
const firstForm = document.forms['first-form'] | |
firstForm.addEventListener('submit', e => { | |
e.preventDefault() | |
fetch(firstFormScriptURL, { method: 'POST', body: new FormData(firstForm)}) | |
.then(response => console.log('Success!', response)) | |
.catch(error => console.error('Error!', error.message)) | |
}) | |
const secondFormSriptURL = '<SECOND FORM SCRIPT URL>' | |
const secondForm = document.forms['second-form'] | |
secondForm.addEventListener('submit', e => { | |
e.preventDefault() | |
fetch(secondFormSriptURL, { method: 'POST', body: new FormData(secondForm)}) | |
.then(response => console.log('Success!', response)) | |
.catch(error => console.error('Error!', error.message)) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does the code in Apps Script look like?