gpt4 book ai didi

javascript - Google Sheet html不调用脚本函数

转载 作者:行者123 更新时间:2023-12-03 06:10:32 25 4
gpt4 key购买 nike

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

<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 而不是 p。使用 type="text"作为值

<!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>

在 Google Apps 脚本中使用 Browser.msgbox

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

关于javascript - Google Sheet html不调用脚本函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39337839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com