简体   繁体   English

你如何将 HTML 变量传递给谷歌应用脚本

[英]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:尝试这个:

  1. run the openDialog() function after filling in serverfunctionname and htmlfilename.填写 serverfunctionname 和 htmlfilename 后运行 openDialog() function。

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.

相关问题 如何遍历数组并将其传递给Google应用程序脚本中的HTML模板 - How to loop through an array and pass it to a HTML template in Google app scripts 如何使用Google表格脚本将Google表格单元格数据添加到html电子邮件中? - How do you add google sheet cell data into an html-email using Google Scripts for Sheets? 如何使用应用脚本向 google 幻灯片演示文稿添加连接线? - How do you add a connecting line to a google slides presentation using app scripts? 如何将webgl函数作为变量传递 - How do you pass webgl functions as variables 您如何从从 index.html 导入的 Javascript 脚本中访问全局变量和函数并在组件中使用它们? - How do you gain access to global variables and functions from Javascript scripts imported from index.html and use them in a component? 如何在HTML属性内的函数调用中将变量作为参数传递? - How do you pass variables as arguments in a function call within HTML attributes? 如何将变量从Angular控制器传递到html <script></script> ? - How do you pass variables from an Angular controller to a html <script></script>? 您如何将html传递给Selenium - How do you pass html to Selenium 在谷歌脚本中将变量传递给 Html 文件 - Passing variables to Html file in google scripts 如何在谷歌应用脚​​本HTML开发中使用tab键 - How to use the tab key in google app scripts HTML development
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM