HTML form to Google Sheet

I’ve been trying to figure out how to do this for a while so maybe it will be useful to someone else. I want to create an HTML form here that sends all the inputs to a google sheet. Demo:

Here is the form:

First Name:

Last Name:

This is where the confirmation message will appear after submission.

And it all ends up in that sheet.

Worked? So here is how to do it:

First, quite obviously, you need and HMTL form. Here's mine:

We'll need to update the link_to_google_script thing after next step.

Then we need a Google Sheet. Go to your Google Drive, create one and save its ID somewhere (that the long string in the url between d/ and /edit).

Now, still in Google Drive, create a new Google Apps Script, remove any code in there and relace it with this:

Just replace the id_of_your_google_sheet with the ID of your own sheet.

Once done, save you script, select Publish, Deploy as web app, make sure that "anyone, even anonymous" has access to the app and Publish. After a bit of authorization procedures, you should get this:

Copy that link and paste it in your HTML instead of link_to_google_script then add at the bottom of your HTML page:

Here you go, it should be working!

5 commentaires:

  1. Hello.
    What if what i want to use a HTML form based on my spreadsheet and then post it over another spreadsheet?
    I can now create another spreadsheet. I need to send my form date to my script which are in the same project.

  2. Were there any CORS issues to fix? Getting a CORS error.

  3. it doesn't work for me, could you help me?

  4. Hi
    It works for me but, I need more to store more than 2 fields and when I put more, It store only two.


Le prix de la baguette de 1954 à 2019

Le sujet n’en finit plus de faire débat : j’ai donc reconstruit une série du prix de la baguette (de 250g) en France (les données concernent...