const FORM_URL = 'YOUR_FORM_EDIT_URL'; const form = FormApp.openByUrl(FORM_URL); const ss = SpreadsheetApp.getActiveSpreadsheet(); const optionsSheet = ss.getSheetByName('Options'); const data = optionsSheet.getDataRange().getValues().slice(1); // Skip header // Reset form form.getItems().forEach(item => form.deleteItem(item)); // Create country question let countryQuestion = form.addMultipleChoiceItem().setTitle('Country'); let countries = [...new Set(data.map(row => row[0]))]; // Unique countries let countryChoices = []; // Loop for sections and cities countries.forEach(country => { let section = form.addPageBreakItem().setTitle(country); section.setGoToPage(FormApp.PageNavigationType.SUBMIT); let cityData = data.filter(row => row[0] === country).map(row => row[1]); let cityQuestion = form.addMultipleChoiceItem().setTitle('City'); cityQuestion.setChoices(cityData.map(city => cityQuestion.createChoice(city))); countryChoices.push(countryQuestion.createChoice(country, section)); }); countryQuestion.setChoices(countryChoices);

Comments

Popular posts from this blog

SDG 2 - 0 hunger not achived

рдорд░ाрдаी рднाрд╖ा рджिрди рдЪिрд░ाрдпू рд╣ोрд╡ो- 2