我已经使用Apps脚本创建了Google表单。表单利用嵌套的for-loop
来将用户定向到表单的正确部分。但是,对于最内层的循环(用户单击以提交其响应),该循环的最终迭代不提供“提交”的选项-它表示“继续至下一部分”。
为您提供一些背景信息。这是一个父母晚上约会系统,用户首先选择一位老师,然后再选择他们希望在那里约会的日期。 for循环的最后一天是星期四,星期四是“继续进行下一步”的日子,应说“提交”。
该表格在星期四循环之前每隔一天有效,我不确定为什么。
我已经指出了需要用星号(*)纠正的代码部分
function updateForms() {
var setUpSheet = ss.getSheetByName('Set-Up')
var times = setUpSheet.getRange(2, 2, setUpSheet.getLastRow()-1,1).getValues()
var teacherNames = setUpSheet.getRange(2, 1, setUpSheet.getLastRow()-1, 1).getValues()
Logger.log(teacherNames)
var appointmentRange = setUpSheet.getRange("C2:C").getValues()
var appointmentRangeCount = appointmentRange.filter(String).length
var appointmentDays = setUpSheet.getRange(2, 3, appointmentRangeCount, 1).getValues()
Logger.log(appointmentDays)
// Opening page where user selects the teacher
var page1 = form.addPageBreakItem()
page1.setTitle('Parent\'s Evening Appointment System')
var item = form.addListItem()
item.setRequired(true)
var teacherPages = []
for (var n in teacherNames) {
var appointmentPages = []
var teacherName = teacherNames[n]
Logger.log(teacherName)
var newPage = form.addPageBreakItem().setTitle(teacherName)
teacherPages.push(item.createChoice(teacherName, newPage))
var item2 = form.addListItem()
item2.setTitle('Choose Day')
item2.setRequired(true)
for (var i in appointmentDays) {
var appointmentDay = appointmentDays[i]
Logger.log(appointmentDay)
var newPage2 = form.addPageBreakItem().setTitle(teacherName + ' ' + appointmentDay)
appointmentPages.push(item2.createChoice(appointmentDay, newPage2))
var item3 = form.addListItem()
item3.setTitle(n + '. Please choose your appointment time. ' + i)
item3.setRequired(true)
item3.setChoiceValues(times)
newPage2.setGoToPage(FormApp.PageNavigationType.SUBMIT)*********
}
item2.setChoices(appointmentPages)
}
item.setTitle('Select your child\'s teacher.')
item.setChoices(teacherPages)
SpreadsheetApp.getActiveSpreadsheet().toast('Task Complete', 'Status');
}
我该如何解决?