【发布时间】:2018-08-15 22:59:33
【问题描述】:
我怀疑应用程序脚本服务器中有一些清理过程会阻止 onclick 命令将值传递给函数。有解决办法吗? 这是我所拥有的:
function func() {
var template = HtmlService.createHtmlOutputFromFile('buttons');
var content = (template.getContent());
Logger.log(content)
MailApp.sendEmail({
to: 'ggg@gmail.com',
subject: 'subject',
htmlBody: content
});
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Answer: <input type="text" id="myText" value="Try one button below">
<p>Try one of the answers below</p>
<button value='ttt' onclick="f1(this)">Try it</button>
<button value='ggg' onclick="f1(this)">Try it</button>
<button value='hhh' onclick="f1(this)">Try it</button>
<button value='eee' onclick="f1(this)">Try it</button>
<script>
function f1(obj){
if (obj.value == 'ttt'){
document.getElementById("myText").value = 'Correct!';
}
else{
document.getElementById("myText").value = 'Wrong answer..';
}
}
</script>
</body>
</html>
【问题讨论】:
标签: javascript html function email google-apps-script