Reputation: 261
I've made a google script which I've published as a web app. I want the "myFunction()" to be called when I press the submit button on the web app. The following doesn't seem to work, and I can't really tell why:
google script file:
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}
function myFunction() {
//does some stuff
}
html file:
<html>
<head>
<script src="Code.gs"></script>
</head>
<body>
<form name="myform">
<!-- some input stuff goes here -->
<input name="Submit" type="submit" value="Update" onclick="myFunction()" />
</form>
</body>
</html>
Upvotes: 0
Views: 278
Reputation: 23
you can try using:
<input name="submit" type="button" value="update" onclick="myFunction()" />
Because, when you write type="submit" the values of the form are sended, and ignore onclick
Upvotes: 0
Reputation: 495
Got it through just a few seconds of Google Search, In your HTML file include the following...
<script>
google.script.run.myFunction();
</script>
Upvotes: 1