Call function in javascript file from html onclick event -
this has been driving me crazy- can't figure out why wont work!
i have 2 files: mypage.html , mycode.gs in google scripts. have deployed html file web app, , want onclick event submit button trigger emailtech function mycode.gs file won't work! when run function straight file, works fine.
i've done few hours of research , tried add <script type="text/javascript" src="mycode.gs"></script>
causes error when refresh web app. have tried calling function in onclick event onclick= "google.script.run.emailtech()"
, onclick= "emailtech()"
neither work. have tried loading emailtech function script tag in header, didn't work either! missing? please help!
mypage.html file:
<script type="text/javascript"></script> <body> <input type="submit" onclick="emailtech();" value="submit" /> </body>
mycode.gs file:
function doget() { return htmlservice.createhtmloutputfromfile('mypage'); } function emailtech(){ logger.log("is firing?"); var message = "this email message"; mailapp.sendemail("xyz@abc.com", "this subject", message ); }
edit: new answer - use google.script.run
.
<script type="text/javascript"></script> <body> <input type="button" onclick="google.script.run.emailtech();" value="submit" /> </body>
Comments
Post a Comment