Javascript 谷歌表单脚本&;HTML赢得';t执行被调用的脚本
我使用一个html页面在Google脚本中创建了一个表单,然后调用javascript函数。当我运行应用程序时,表单加载正常,但它不会执行脚本。我怎样才能做到这一点 下面是我尝试做的一个例子:Javascript 谷歌表单脚本&;HTML赢得';t执行被调用的脚本,javascript,html,google-apps-script,Javascript,Html,Google Apps Script,我使用一个html页面在Google脚本中创建了一个表单,然后调用javascript函数。当我运行应用程序时,表单加载正常,但它不会执行脚本。我怎样才能做到这一点 下面是我尝试做的一个例子: <html> <!--Create Sign Out Form--> <form id="signOut"> <div> Destination: <select name="destination">
<html>
<!--Create Sign Out Form-->
<form id="signOut">
<div>
Destination:
<select name="destination">
<option value="lunch">Lunch</option>
<option value="meeting">Client Meeting</option>
<option value="vacation">Vacation</option>
<option value="sick">Out Sick</option>
<option value="personal">Personal</option>
<option value="home">Working from Home</option>
<option value="scedule">Reduced Schedule</option>
</select>
</div>
<div>
Supervisor:
<select name="supervisor" onselect="google.script.run.withUserObject(this.parentNode).populate(destination)"></select>
</div>
<div>
Start Date:
<input type="date" name="startDate" onselect="google.script.run.withUserObject(this.parentNode).SignOutLibrary.dateSelect()"/>
</div>
<div>
End Date:
<input type="date" name="endDate" onselect="google.script.run.withUserObject(this.parentNode).SignOutLibrary.dateSelect()"/>
</div>
<div>
Details:
<textarea type="text" name="details" style="width: 150px; height: 75px;"></textarea>
</div>
<div>
<input type="button" value="Submit"
onclick="google.script.run
.sendRequest(this.parentNode)"/>
</div>
</form>
</html>
标志库:
function dateSelect() {
var app = UiApp.createApplication();
var handler = app.createServerHandler("change");
var date = app.createDatePicker().setPixelSize(150, 150).addValueChangeHandler(handler).setId("date");
app.add(date);
return app;
}
function change(eventInfo) {
var app = UiApp.getActiveApplication();
app.add(eventInfo.parameter.date);
return app;
}
尝试使用this.form更改代码中的所有this.parentNode
我很快查看了文档,也许它会起作用,对不起,我现在无法测试我的答案您没有显示
populate()
-希望您有这样的功能。如果您这样做了,那么您的下一个任务将是找到一种方法来获取作为参数传递的destination
的值。在它现在的形式中,它是未定义的。看
您不能直接使用脚本运行程序调用库函数,请参阅上的部分。您需要将中间函数添加到“本地”gs中,以与库函数(如SignOutLibrary.dateSelect()
)进行接口
该库使用UiApp,而其余代码使用Html服务。选择一个或另一个,因为您不能像这样混合它们。控制台中有错误吗?我还没有遇到过。(假设您谈论的是记录器,因为没有控制台:/)我在文档中看到有onclick,有人知道onselect是否受支持吗?另一个更新:我的提交按钮的onclick脚本不起作用?我甚至尝试从头开始创建一个全新的库和表单,以确保它不是我选择的某个选项,并且它们仍然没有运行。AFAIK是用于Google Forms应用程序的,而不是用于使用Google Apps脚本的HTML服务创建的表单。应移除此标签。
function dateSelect() {
var app = UiApp.createApplication();
var handler = app.createServerHandler("change");
var date = app.createDatePicker().setPixelSize(150, 150).addValueChangeHandler(handler).setId("date");
app.add(date);
return app;
}
function change(eventInfo) {
var app = UiApp.getActiveApplication();
app.add(eventInfo.parameter.date);
return app;
}