Connecting Spreadsheet to Username on Simple Login Portal

94 views
Skip to first unread message

Naomi Hinton

unread,
May 8, 2023, 1:38:09 PM5/8/23
to Google Apps Script Community

Hello, 


I'm trying to connect the spreadsheet to the information that's typed in the button. Before attempting to connect the spreadsheet I was getting 'undefined clicked the button' when 'running' the log, instead of a typed in name like 'joe' or 'ana'...So I continued to try to connect the spreadsheet, but it's still not connecting. Maybe it has something to do with the 'e.parameter' ?

TypeError: Cannot read properties of undefined (reading 'parameter')



page.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1> Hello </h1>
<label>Name:</label><input type="text" id="username">
<button id= "btn"> Run it! </button>


<script>
document.getElementById("btn").addEventListener("click",doStuff);
function doStuff(){

var uname = document.getElementById("username").value;
google.script.run.userClicked(uname);
document.getElementById("username").value ="";
}
</script>
</body>
</html>

function doGet(e){

Logger.log(e.parameter);
return HtmlService.createHtmlOutputFromFile("page");
}

function userClicked(name){
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName("Data");

ws.appendRow([name]);


//Logger.log(name + "Clicked the Button");
}

CBMServices Web

unread,
May 8, 2023, 2:48:39 PM5/8/23
to google-apps-sc...@googlegroups.com
The error is from this line:

Logger.log(e.parameter);
return

I would suggest just commenting line out as you don't have any parameters that you are using.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/7c49d384-03cc-4067-ac67-596c5c8efacfn%40googlegroups.com.

Naomi Hinton

unread,
May 8, 2023, 3:09:19 PM5/8/23
to google-apps-sc...@googlegroups.com
Thank you , I will try it now :) 



--
Naomi M. Hinton
Prague, Czech Republic
 


Naomi Hinton

unread,
May 8, 2023, 3:12:37 PM5/8/23
to google-apps-sc...@googlegroups.com
It worked! Thanks again !!
Reply all
Reply to author
Forward
0 new messages