1

I have a form created using the google scripts HtmlService. I need to send the data captured once the form is submitted to a google spreadsheet, so I need to communicate withe the script on the server side. I have been following the google documentation on HtmlService, and from the documentation, I have come out with this sample code, at least to test the calling of a function on the server from the html using google.script API, but it doesn't work for me:

The google Apps Script:

function doGet(e) {
  Logger.log("Creating page...");
  return HtmlService.createTemplateFromFile("myFile").evaluate();
}

function test() {
  return "Testing";
}

And the html file:

<html>
  <SCRIPT>
    function evaluate(form) {
      var a = google.script.run.test();
      form.fieldName.value = a;
    }
  </SCRIPT>
    <form>
       <INPUT type = text name ="fieldName" class = "input_field" > 
       <INPUT TYPE="button" NAME="buttonSubmit" Value="Guardar"    onClick='evaluate(this.form)' >
  </form>
</html>

¿Whats wrong with this code? Any insights on this would be really appreciated, or alternative ways to do this.

1 Answer 1

3

HtmlService is used for primarily client-side functions not server based operations. However you can call a server function with google.script.run.FunctionName(parameter).

Example

<input type='button' value="Click me" onclick='google.script.run.processForm(this.parentNode)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.