0

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>
1
  • How do you know that the function is called? Is your Code.gs in the same directory as your HTML file (if not, it will not be included). Put a test alert() or console.log() as the very first line in myFunction(), to see if the function is actually getting called. Commented Jul 1, 2014 at 13:39

2 Answers 2

1

Got it through just a few seconds of Google Search, In your HTML file include the following...

<script>
  google.script.run.myFunction();
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

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

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.