Google sheet html not calling script function

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

I have the following html code in my google app. IT should call the function below but I'm getting nothing. I've used the same script throughout my code until now

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

Here is the code for the function

function generate_grades_for_lesson(formObject) {     msgBox("Hello"); } 

Any help is appreciated

回答1:

Use form instead of p around the form elements. Use type="text" for 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> 

Use Browser.msgbox in google apps script

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!