Add basic data to a Google spreadsheet using a simple HTML form

I have a form with a name and email address that a user can fill out.

enter image description here

Now, if the user clicks the submit button, I want to send the data to the table ideally, without using some magic on the server side.

This is my form:

<form method="post" action="SOME-ACTION-HERE" accept-charset="UTF-8">
    <input type="text" name="newletter_name" placeholder="Name">
    <input type="text" name="newletter_email" placeholder="Email">
    <input type="submit" value="Subscribe" />
</form>

Is there a way to do this using my own HTML form. I know that you can create a Google form for a given distribution sheet, but I want to use it as a kind of widget.

+3
source share
1 answer

, . .
, , google, :)
, JS ( ).
, , - google script, :  :

HTML :

<form  id="form" method="get" action="https://script.google.com/macros/s/AKfycbxeKTVlTkqSGLIRphBrzACjuWlfmejbPIG7NqBxx-7Us7lnqLw/exec" accept-charset="UTF-8">
    <input type="text" name="newletter_name" placeholder="Name">
    <input type="text" name="newletter_email" placeholder="Email">
    <input type="submit" value="Subscribe"/>
</form>

google script:

function doGet(e){
  var vals=[];
  vals.push(new Date());
  for(var i in e.parameter){
    vals.push(e.parameter[i]);
  }
  SpreadsheetApp.openById("0Ao02g19G1-G-dElQQW92ekZWa0lGRGREYUpHRWQwTVE").appendRow(vals);
  return ContentService.createTextOutput("added");
}

,

:
Google script ( , script ).
script, . , URL-, HTML-. : https://script.google.com/macros/s/AKfycbxeKTVlTkqSGLIRphBrzACjuWlfmejbPIG7NqBxx-7Us7lnqLw/exec

, .

+10

All Articles