Fairly new to this process! Trying to set up a form to submit and then have the data go to a google sheet. I used this guide as a template: https://github.com/levinunnink/html-form-to-google-sheet?tab=readme-ov-file, but for some reason the data isnt being received. No errors on the console log either. Is there a better way to go about doing this?
$(document).ready((function () {
window.addEventListener("load", function() {
const form = document.getElementById('#userForm');
$( "#submitBtn" ).on( "submit", function() {
e.preventDefault();
const data = new FormData(form);
const action = e.target.action;
fetch(action, {
method: 'POST',
body: data,
url:"MY GOOGLE URL",
})
.then(() => {
alert("Success!");
})
} );
});
<form class="section__form" id="userForm">
<label>YOUR NAME:
<input type="text" class="section__form-input" id="Name" name="Name" placeholder="Your Name" required></label>
<label>EMAIL ADDRESS:
<input type="email" class="section__form-input" id="Email" name="Email" placeholder="Email Address" required>
</label>
<button type="submit" class="section__cta" id="submitBtn">LEARN MORE</button></form>