[英]Running a Google Sheets App script function from an HTML page with form values returned
I'm trying to return the values that a user enters into a form on a webpage in a google app script to a function and then notify the user with a response. 我正在尝试将用户在Google应用程序脚本中的网页上输入的表单的值返回给函数,然后用响应通知用户。
Here is my app script 这是我的应用脚本
function onOpen() {
openLogin();
SpreadsheetApp.getUi()
.createMenu('Dialog')
.addItem('Open', 'openLogin')
.addToUi()
}
function openLogin() {
var html = HtmlService.createHtmlOutputFromFile('index');
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, 'Login Form');
}
function checkLogin() {
SpreadsheetApp.getUi().alert('Hello, world!');
}
I'm trying to get checkLogin to fire off. 我正在尝试让checkLogin启动。 Here is the HTML code.
这是HTML代码。
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form>
First name:
<input type="text" name="user_name"><br><br>
Last name:
<input type="password" name="user_password"><br><br>
Staff or Student?
<br>
<input type="radio" name="staff" value="staff" checked> Staff<br>
<input type="radio" name="student" value="student"> Student<br>
<br><br>
<input type="button" value="OK"
onclick="google.script.host.close()" />
<input type="button" value="Close"
onclick="google.script.run.checkLogin()" />
</form>
</body>
</html>
My mistake, I had the OK and Close function calls mixed up. 我的错误是我将OK和Close函数调用混在一起。 It should have been
应该是
<input type="button" value="OK"
onclick="google.script.run.checkLogin()" />
<input type="button" value="Close"
onclick="google.script.host.close()" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.