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.