Home > Enterprise >  Apps script: Get html form values inputted into a web app
Apps script: Get html form values inputted into a web app

Time:09-25

I am working on a script that requires html form data to be inputted to a web app, I then want to be able to process that form data and put it on a google sheet. The thing is I can't seem to do that. Here is my code:

Index.html

<form id="Form" onsubmit="event.preventDefault(); 
google.script.run.getData(this)">
  <input type="text" name="firstname">
  <input type="submit">
</form>

Code.gs

function getData(data) {
    var sheet= SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Logs');
    sheet.getCurrentCell().setValue(data.name);
}

What am I doing wrong?

CodePudding user response:

Check the enter image description here

Output:

enter image description here

  • In this example, my current active cell is in A1
  • Related