Skip to content

Instantly share code, notes, and snippets.

@heysujal
Created August 12, 2023 09:28
Show Gist options
  • Save heysujal/63be12fe85d1db616a59314e6818e8b2 to your computer and use it in GitHub Desktop.
Save heysujal/63be12fe85d1db616a59314e6818e8b2 to your computer and use it in GitHub Desktop.
Save html fom data to google sheets directly without using App Scripts.
const regForm = document.querySelector("#regForm");
regForm.addEventListener("submit", () => {
event.preventDefault();
const fullName = document.querySelector("#fullName");
const email = document.querySelector("#email");
const phone = document.querySelector("#phone");
const qual = document.querySelector("#qual");
const state = document.querySelector("#state");
const city = document.querySelector("#city");
const district = document.querySelector("#district");
const pincode = document.querySelector("#pincode");
const url =
"https://docs.google.com/forms/u/0/d/e/1FAIpQLSecZafUMyX1f7bSLyFA6SPUydZgsGArbE23hYlg/formResponse";
fetch(url, {
method: "POST",
mode: "no-cors",
body: `entry.871680=${fullName.value}&entry.1673746=${phone.value}&entry.20737=${email.value}&entry.195961=${qual.value}&entry.85149=${state.value}&entry.175299=${district.value}&entry.173113=${city.value}&entry.120172=${pincode.value}&dlut=16303558&fvv=1&draftResponse=%5Bnull%2Cnull%2C%226039705974122733004%22%5D&pageHistory=0&fbzx=6039705974122733004`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}).then((response) => {
// console
console.log("Data submitted successfully");
window.location.href = "/success.html";
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment