【发布时间】:2018-06-20 00:05:08
【问题描述】:
所以我有一个包含姓名列表的谷歌表格,我希望谷歌表单上的多选框填充这个列表。 我已经创建了一个脚本来基于此列表创建一个下拉菜单,但无法让多项选择起作用。
这是创建下拉菜单的脚本。
function updateForm(){
// call your form and connect to the drop-down item
var form = FormApp.openById("Form ID");
var namesList = form.getItemById("Data-Item-ID").asListItem ();
// identify the sheet where the data resides needed to populate the drop-down
var ss = SpreadsheetApp.getActive();
var names = ss.getSheetByName("Sheet Name");
// grab the values in the first column of the sheet - use 2 to skip header row
var namesValues = names.getRange(2, 26, names.getMaxRows() - 1).getValues();
var name = [];
var jjj = -1;
// convert the array ignoring empty cells
for(var i = 0; i < namesValues.length; i++)
if((namesValues[i][0] != "") & (namesValues[i][0] != "TOTALS") &
(namesValues[i][0] != "Total Volunteers"))
{
jjj +=1;
name[jjj] = namesValues[i][0];
}
// populate the drop-down with the array data
namesList.setChoiceValues(name);
}
【问题讨论】:
-
您所说的“无法使多项选择起作用”是什么意思?你有错误吗?你试过什么?
标签: google-apps-script google-sheets google-forms