-1

I have to search, but did not find the javascript code that will update the google spread sheet using the post method from a form.
Thanks in advance.

ecbrodie
  • 11,246
  • 21
  • 71
  • 120
  • You may get better answers from the *Web App* stack. http://webapps.stackexchange.com/search?q=apps+script+update+sheet – Paulb Jun 18 '16 at 12:33

2 Answers2

0

Based from this documentation, you can use the batchUpdate method which lets you update any of these spreadsheet details. Changes are grouped together in a batch so that if one request fails, none of the other (potentially dependent) changes is written.

For example, to update just the Title of a spreadsheet, this would be the request:

Request:
POST .../v4/spreadsheets/spreadsheetId:batchUpdate

Request body:

{
  "requests": [{
      "updateSpreadsheetProperties": {
          "properties": {"title": "My New Title"},
          "fields": "title"
        }
    }]
}

Examples on GitHub.

Check these related tickets:

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
0

You will have to do all the OAuth consents, the following example works great. https://developers.google.com/sheets/api/quickstart/js

Make sure the listMajors() works in your code.

than on your form.

<form method="post" action="somefile-to-receive-your-data.php" onsubmit="return doSomething();">

as for the writing api code.

try:

function doSomething() {
  gapi.client.sheets.spreadsheets.values.update({
        spreadsheetId: 'YourSpreadSheetID',
        range: 'Sheet1!A4:D5',
        majorDimension: "ROWS",
        valueInputOption: 'USER_ENTERED',
        values: [['="20"&LEFT(E4,6)', "9999", "Name", "03-19-17"],
                 ["9999", "Name", "03-19-17"],'="20"&LEFT(E4,6)']
  }).then(function(response) {
     console.log(response);
  });
}