我想通过脚本编辑器在Google Sheets上创建一个自定义菜单,该菜单从HTML文件中创建一个弹出窗口或模态,显示HTML文件中链接的Google表单。到目前为止,这就是我所拥有的。
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu("Records")
.addItem("Dump","menuItem1")
.addItem("New Patient Record", "menuItem2")
.addToUi();
}
function menuItem1() {
SpreadsheetApp.getUi ()
.alert('You clicked the first menu item!');
}
function menuItem2() {
var htmlOutput = HtmlService.createHtmlOutputFromFile('form')
.setWidth(250)
.setHeight(80)
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Form');
}
至于我的html文件,它的名称是form.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form action='https://docs.google.com/forms/d/e/1FAIpQLSexWWi3ru1bzwDVhG1TU0hqAeS6VCi-6LDju8KqG7zZv1tBxg/viewform' method='get' id='foo'></form>
<script>document.getElementById('foo').submit();</script>
</body>
</html>
这是我现在拥有的pop/modal,它不调用谷歌表单链接modalinsheetspicture
在form.html文件中,将表单插入iframe中。
<iframe src="https://docs.google.com/forms/d/e/123/viewform" width="100%" height="100%"></iframe>