使用Google脚本为Google表单下拉菜单设置“值”和“根据答案转到部分”

问题描述 投票:1回答:2

我使用Google表格来存储Google表单下拉菜单的“值”和“根据答案转到部分”。如何使用Google Apps脚本为下拉菜单设置“值”和“根据答案转到部分”?

我可以使用脚本从Google工作表中设置值,但无法使用工作表和脚本为下拉菜单设置“根据答案转到相应部分”。

我已经在用于设置值的脚本中具有下拉列表的listItem。我尝试使用createChoice(value,navigationItem)并设置“转到部分”,然后使用setChoiceValues(values),但在表单上我一切都设置为“ Choice”。

提前感谢!

google-apps-script google-form
2个回答
1
投票

如果您只想创建一个下拉菜单项,根据您使用Apps Script的选择,将您带到另一个部分,那么类似的事情呢?

function createDropdownExample() {
  var form = FormApp.openById('your_form_id');
  var item = form.addMultipleChoiceItem();
  item.setTitle('Do you prefer cats or dogs?');  
  var dogsPage = form.addPageBreakItem().setTitle('Dogs');
  var catsPage = form.addPageBreakItem().setTitle('Cats');
  var dogsChoice = item.createChoice('Dogs', dogsPage);
  var catsChoice = item.createChoice('Cats', catsPage);
  item.setChoices([dogsChoice, catsChoice]);
}

我希望这是您想要的。


0
投票

已解决。

© www.soinside.com 2019 - 2024. All rights reserved.