Skip to content

comptometer/Form-Google-Sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Sheet & WebForm

Save Web/HTML Form Data to Google Sheets

GitHub

Steps

A. Form (HTML)

  1. Import Script to your HTML File
<script src="Relative/path/to/WebForm.js"></script>  <!-- Inside <head> -->
  1. Make your desired form
<form method="post" autocomplete="off" name=<FORM_NAME>>
      <input type="email" title="Type your email address" id="email" name="EMAIL" placeholder="Your Email Address" required>
      <textarea id="message" title="Type your Message" name="MESSAGE" placeholder="Your Message ..." required></textarea>
      <input type="submit" title="Send your Message" value="Send">
</form>
  1. Change the <FORM_NAME> to your desired name
  2. All Form Elements must have names in Block Letters

B. Google Sheet

  1. Goto Google Sheet and create a blank sheet
  2. Name the Fields as needed in your Form in Block Letters
  3. Number of Fields must be as same as the Fields of your Form
  4. go to Tools > Script Editor
  5. Copy and paste the file WebForm.gs to the Script Editor
  6. Change the <SHEET_NAME> with your sheet name
  7. deploy and copy the <DEPLOYMENT_ID>

C. Form (JS)

  1. Add the Script to Your HTML file
document.addEventListener('submit',e=>{
    e.preventDefault(); //to stop the form being post
    var w = new WebForm(<DEPLOYMENT_ID>,<FORM_NAME>);//create an object
    w.submit(); // call to submit data
        })
  1. Change <DEPLOYMENT_ID> and <FORM_NAME> with yours

*NB:

  1. Names of Form Elements should be as same as field names of Google Sheet
  2. All Names are case sensitive, It is recommended to make them in Block letter

Caution

  1. There are no Guarantee of Security
  2. There are some quotas of Google Sheet. So it is not for your next Big Tech type website