Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function updateForm(){
- // call your form and connect to the drop-down item
- var form = FormApp.openById("Your Form ID");
- var namesList = form.getItemById("The Drop-Down List ID").asListItem();
- // identify the sheet where the data resides needed to populate the drop-down
- var ss = SpreadsheetApp.getActive();
- var names = ss.getSheetByName("Name of Sheet in Spreadsheet");
- // grab the values in the first column of the sheet - use 2 to skip header row
- var namesValues = names.getRange(2, 1, names.getMaxRows() - 1).getValues();
- var studentNames = [];
- // convert the array ignoring empty cells
- for(var i = 0; i < namesValues.length; i++)
- if(namesValues[i][0] != "")
- studentNames[i] = namesValues[i][0];
- // populate the drop-down with the array data
- namesList.setChoiceValues(studentNames);
- }
Add Comment
Please, Sign In to add comment