How To Submit An HTML Form To Google Sheets Without Google Forms PDF
How To Submit An HTML Form To Google Sheets Without Google Forms PDF
Get started
Member preview
David McCoy
Expat. Web developer. CTO of
Hipsters of the Coast.
Jun 10, 2017 · 5 min read
How to Submit an
HTML Form to
Google Sheets…
without
Google Forms
Google Forms is a great service.
Easy, good-looking forms with re-
sults stored in Google Sheets. But
what if you don’t want your form to
look like a Google Form? How can
you build your own HTML form and
record the responses in Google
Sheets?
Setting up the
Google Sheet
Since we’re skipping Google Forms,
head straight to Google Sheets and
create a new spreadsheet. The only
thing we’ll need to do to the spread-
sheet itself is assign column names
for each form Meld we’ll be collect-
ing.
Building the
HTML Form
So we’ve got a Google Sheet set up
with a column for each of our form
Melds, as well as a script that will ac-
cept form data in an AJAX request
and write it to the spreadsheet. All
that’s left is to create an HTML form
so that we can collect some informa-
tion and persist it in our Google
Sheet!
A Google Form-less
Google Form
Well, it took a bit more work than
should have have been necessary,
but we did it! By using Google
Sheets in conjunction with Google
Scripts, we were able to build our
own Google Form…without being
forced to use a Google Form. Why
there isn’t a Google API to do this is
beyond me…but at least it’s possi-
ble!
Update! If You’re
Having Issues…
Thanks to Joel Aguero for address-
ing some issues people are having
using this guide. His response is
here and reproduced below.
1. CORS Issues
If you’re seeing an error like the
following: “No ‘Access-Control-
Allow-Origin’ header is present
on the requested resource,” dou-
ble-check you’re making a GET
request and not a POST request.
3. Accessing Parameters
If you’re struggling to access pa-
rameters or properly pass data,
try attaching them to the end of
the url instead:
https://script.google.-
com/macros/s/…/exec?9rst-
Name=Joel
If you go this route, I recom-
mend using encodeURICompo-
nent to escape special characters
(eg: the “+” in test+1@exam-
ple.com).
4. Request Libraries
I used the Fetch API to make the
request because React suppos-
edly ships with a polyMll by de-
fault. If you aren’t using React, I
recommend the popular pack-
age request or Mnding a polyMll
so you can ober cross-browser
support.
Web Development Google Forms
Google Scripts
1.1K 39