【发布时间】:2019-01-16 12:23:47
【问题描述】:
我是 .gs 的新手,所以这应该不难。
我有一个 Google 电子表格,其中有一列中的值(比方说 A 列)。 我使用 .gs 创建了一个自定义菜单,用户将在其中选择一个选项。
单击其中一个选项(新组件)会出现一个弹出窗口,其中包含一个下拉菜单,用户应在其中从值中进行选择。
CustomMenu.gs
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('bq Library Menu')
.addItem('Add new component', 'newComponent')
.addSeparator()
.addSubMenu(ui.createMenu('Modify existing component')
.addItem('Remove component', 'removeComponent'))
.addToUi();
}
function newComponent() {
var html = HtmlService.createHtmlOutputFromFile('NewComponentForm')
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showModalDialog(html, 'New Component Form');
}
NewComponentForm.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h2>Clickable Dropdown</h2>
<p>Select manufacturer from the list</p>
<div class="dropdown">
<button onclick="loadManufacturers()" class="dropbtn">Dropdown</button>
<div id="myDropdown" class="dropdown-content"></div>
</div>
</body>
我希望下拉菜单显示电子表格 A 列中的所有元素。我尝试了几个选项,但都没有获得所需的结果。
那么,我需要如何继续实现下拉填充过程?
【问题讨论】:
标签: javascript html google-apps-script drop-down-menu google-sheets