Google App 脚本中的简单 Web 应用程序 - 按钮不起作用

我无法让我的脚本正常工作。HTML 加载正常,但单击按钮时没有执行任何操作,所以我认为 .addEventListener("click",function) 有问题,但我不知道是什么。我根本看不到记录器中的任何内容。


我以前写过类似的网络应用程序,但无法找到问题的根源;有人有什么想法吗?


function doGet(e){


  return HtmlService.createTemplateFromFile("Form").evaluate();

}


function userClicked(clientInfo){

  var ss = SpreadsheetApp.openById('Sheet_ID');

  var ws = ss.getSheetByName('Form Inputs');

  

  //Add new row for form submission

  ws.appendRow([clientInfo.clientName, clientInfo.partnerName, clientInfo.account_1, clientInfo.account_2, clientInfo.account_3]);

  

//run newclient function

  newclient(clientInfo.clientName, clientInfo.partnerName, clientInfo.account_1, clientInfo.account_2, clientInfo.account_3);

  

  }


//Function used in HTML file to generate HTML output from "page-js" and "page-css"

function include(filename){return HtmlService.createHtmlOutputFromFile(filename).getContent();}

HTML 如下:


三国纷争
浏览 121回答 3
3回答

梵蒂冈之花

Logger.log是一种仅在服务器端运行的 Apps 脚本方法 (code.gs)对于来自客户端 (Javascript) 的日志,请console.log改用。来自客户端的控制台日志不会出现在您的 Apps 脚本日志或执行中您可以在浏览器的开发者控制台中找到这些日志 您的按钮可能工作正常,但您的 Javascript 函数中存在一些错误在这种情况下,您将在开发者控制台中看到错误

翻阅古今

我发现它不起作用,因为我在脚本标记和 JavaScript 代码开头之间留了一个空格,但没有注意到。感谢所有回答的人

胡说叔叔

您可以直接从谷歌应用脚本文档尝试这个:var ui = DocumentApp.getUi();var response = ui.alert('are you there?', ui.ButtonSet.OK);// Process the user's response.if (response == ui.ButtonSet.OK) {  Logger.log('The user clicked "OK."');} var ui = DocumentApp.getUi();var response = ui.alert('are you there?', ui.ButtonSet.OK);// Process the user's response.if (response == ui.ButtonSet.OK) {  Logger.log('The user clicked "OK."');} 
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript