I'm currently trying to write a form in HTML that passes its input to a spreadsheet. I did it as shown in the following video: https://www.youtube.com/watch?v=RRQvySxaCW0&list=PLv9Pf9aNgemt82hBENyneRyHnD-zORB3l. The problem is that the Logger in addInfo() function isn't working when the button is clicked (In the Logs is no "Hey" when the button got clicked).
My Code.gs (Google Apps Script) file:
function doGet(){
return HtmlService.createHtmlOutputFromFile("index");
}
function addInfo(){
Logger.log("Hey");
}
My index.html file:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<button id="btn">Klick mich</button>
<script>
document.getElementById("btn").addEventListener("click",doStuff);
function doStuff(){
google.script.run.addInfo();
}
</script>
</body>
</html>
Is anyone knowing why it is not working like that? I appreciate your help.
Best regards, Max
The logs of triggers like doGet() cannot be seen from the Apps Script IDE Logger.
Follow these steps to achieve what you are aiming for:
Logger.log use console.log.For more information regarding this process, check this post where they explain more extensively the use of the Stackdrive Logger for Apps Script.
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With