可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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); }