I have a google sheets script that allows the user to enter certain data. I want to be able to pass these values back to a function in the google app script when the user clicks OK.
Here is the Google sheet script I am trying to get to work. The function checkLogin does get called until I try to pass the values to it from the web page.
The gscript
function onOpen() {
openLogin();
SpreadsheetApp.getUi()
.createMenu('Dialog')
.addItem('Open', 'openLogin')
.addToUi()
}
function openLogin() {
var html = HtmlService.createHtmlOutputFromFile('index');
SpreadsheetApp.getUi()
.showModalDialog(html, 'Login Form');
}
function checkLogin(user_name, user_password, staff, student) {
SpreadsheetApp.getUi().alert(user_name);
}
and the web page code is as follows:
<!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.run.checkLogin(user_name, user_password, staff, student)" />
<input type="button" value="Close"
onclick="google.script.host.close()" />
</form>
</body>
</html>
I hope someone can point me in the right direction. Thanks