谷歌表html不调用脚本功能

Google sheet html not calling script function

本文关键字:脚本 功能 调用 html 谷歌      更新时间:2023-09-26

我有以下html代码在我的谷歌应用程序。它应该调用下面的函数,但我什么也没得到。到目前为止,我在所有代码中都使用了相同的脚本

<div id= "right_column">
    <p>
      <input type="button" value="Enter Grades for Selected Lessons"
      onclick="google.script.run.withSuccessHandler(showMsgForLoginAttempt).generate_grades_for_lesson(this.parentNode)"/> 
    </p>
</div>
下面是函数 的代码
function generate_grades_for_lesson(formObject) {
    msgBox("Hello");
}

感谢您的帮助

在form元素周围使用form而不是p。使用type="text"代替value

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <div id= "right_column">
    <form>
      <input type="text" name="grades" placeholder="Grades..."> 
      <input type="button" value="Enter Grades for Selected Lessons" 
      onclick="google.script.run.withSuccessHandler(showMsgForLoginAttempt).generate_grades_for_lesson(this.parentNode)"/> 
    </form>
    </div>
  </body>
</html>
<script>
function showMsgForLoginAttempt() {
  console.log("success");
}
</script>

使用浏览器。Msgbox在Google apps脚本

function generate_grades_for_lesson(formObject) {
  Browser.msgBox("Grades: " + formObject.grades);
}