这里出了点问题,我从其他有类似问题的人那里得到的所有建议似乎都没有用.
我有两个文件:google脚本中的myPage.html和myCode.gs.我已经将html文件部署为Web应用程序,并且我已经找到了(如果有帮助)如何使用'submit'按钮的onclick事件来触发myCode.gs文件中的emailTech函数就好了.
现在我想将html文件中的文本框中的值插入从onClick事件调用的电子邮件中.我试过document.getElementById('textBoxId').value,但是我得到以下错误"参考错误:"文档"未定义."是什么给出的?
myPage.html文件:
<html>
<head>
<title>Test Page</title>
</head>
<body>
<input type="button" onClick="google.script.run.emailTech();" value="Submit" />
<input type="text" value=" " id = "textBox" name = "textBox" />
</body>
<script type="text/javascript">
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
myCode.gs文件:
function doGet() {
return HtmlService.createHtmlOutputFromFile('myPage');
}
function emailTech(){
var nameBox = document.getElementById('textBox').value;
var message = "This is the text box value" + nameBox;
MailApp.sendEmail("123@xyz.com", "This is the subject", message );
}
Run Code Online (Sandbox Code Playgroud)