我正在尝试从表单中获取 ID 并针对 CODE.gs 中的函数运行该 ID,该函数检查该 ID 的电子表格并在 HTML 中返回该名称。现在当它运行时它给了我一个未定义的。HTML:<!DOCTYPE html><html> <head> <base target="_top"> <script> var result var id function getName() { var id = document.getElementById("SearchID").value; document.getElementById("SearchID").value = ""; var result = google.script.run.findName(id); document.getElementById("NameDisp").innerHTML = result; } </script> </head> <body> Welcome to Verify. To begin, enter an ID below.<br><br> Student ID:<input type="text" id="SearchID" name="id" size="10"> <input type="button" name="search" type="submit" value="Go" onclick="getName();";/> <div id="NameDisp"></div> <div id="grade"></div> <br><br> <input type="button" value="Close" onclick="google.script.host.close()" /> </body>代码.GSfunction findName(empID) { var ss = SpreadsheetApp.getActive(); var sh = ss.setActiveSheet(ss.getSheetByName('STU401'), true); var last=ss.getLastRow(); var data=sh.getRange(1,1,last,5).getValues(); // create an array of data from columns A and B for(nn=0;nn<data.length;++nn){ if (data[nn][0]==empID){break} ;// if a match in column A, break loop } var empName = data[nn][4]return empName}
添加回答
举报
0/150
提交
取消