如何使用Google Apps脚本设置“值"和“根据答案转到章节".Google表单下拉菜单? [英] How to use Google Apps Script to set the "values" and "go to section based on answer" for a Google Form dropdown?

查看:85
本文介绍了如何使用Google Apps脚本设置“值"和“根据答案转到章节".Google表单下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I using Google Sheets to store the "values" and "go to section based on answer" for a Google Form dropdown. How can I use the Google Apps Script to set both "values" and "go to section based on answer" for the dropdown?

我可以使用脚本从Google表格设置值,但不能使用表格和脚本为下拉菜单设置根据答案转到章节".

I am able to set values from Google Sheet using the script, but I am not able to set the "go to section based on answer" for the drop-down using the sheet and script.

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

I already have the listItem of the dropdown in the script which I am using to set values. I tried using createChoice(value, navigationItem) and with it to set the "go to section" and then used setChoiceValues(values) but I everything gets set as "Choice" on the form.

推荐答案

如果您只想创建一个下拉菜单项,根据您使用Apps脚本的选择,该下拉菜单项会将您带到其他部分:

If you just want to create a dropdown item that takes you to a different section depending on the choice using 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]);
}

这篇关于如何使用Google Apps脚本设置“值"和“根据答案转到章节".Google表单下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆