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!

4 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.
    Thanks.

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

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

    RépondreSupprimer

Cheval de fer, acte II

La première partie est ici. Quand John Kennedy s’y était installé au tout début des années 1790, Manchester n’était encore qu’un gros bour...