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.
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. Here is the HTML code.
<!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. It should have been
<input type="button" value="OK"
onclick="google.script.run.checkLogin()" />
<input type="button" value="Close"
onclick="google.script.host.close()" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.