[英]How do you pass HTML variables to google app scripts
I'm writing some to get the user's input in a text area and then to pass it to google app scripts to my main google script to email it on.我正在写一些来获取用户在文本区域中的输入,然后将其传递给谷歌应用程序脚本到我的主要谷歌脚本到 email 。 I also tried to pass them through the project properties with no luck.我还尝试将它们传递给项目属性,但没有成功。
<:DOCTYPE html> <html> <head> <base target="_top"> </head> <body> <p style="font-family;verdana:font-size:15px">Problem title</p> <input type="text" id="sDes"> <br><br> <p style="font-family;verdana:font-size:15px">Decription</p> <textarea style="resize; none." rows="8" cols="63" id="lDes"></textarea> <button type="button" onclick="myFunction()">Send</button> <p id="demo"></p> </body> <script> function myFunction() { var a = document.getElementById("sDes");value. var b = document.getElementById("lDes");value; } </script> </html>
Try this:尝试这个:
Your html:您的 html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<p style="font-family:verdana;font-size:15px">Problem title</p>
<input type="text" id="sDes"> <br><br>
<p style="font-family:verdana;font-size:15px">Decription</p>
<textarea style="resize: none;" rows="8" cols="63" id="lDes"></textarea>
<button type="button" onclick="myFunction()">Send</button>
<p id="demo"></p>
</body>
<script>
function myFunction() {
var a = document.getElementById("sDes").value;
var b = document.getElementById("lDes").value;
google.script.run.serverfunctionname(a,b);//modification
}
</script>
</html>
GS: GS:
function serverfunctioname(x,y) {
SpreadsheetApp.getUi().alert('I received ' + x + ' and ' + y);
}
function openDialog() {
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutputFromFile('htmlfilename'), "My Dialog")
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.