google form ดึงข้อมูลจาก google sheet
Script ส่งข้อมูลจาก Google Sheet ไปยัง Google Form
function updateForm(){
// call your form and connect to the drop-down item
var form = FormApp.openById(“****formurl****“);
var namesList = form.getItemById(“****data-item-id****“).asListItem();
// identify the sheet where the data resides needed to populate the drop-down
var ss = SpreadsheetApp.getActive();
var names = ss.getSheetByName(“Sheet1”);
// grab the values in the first column of the sheet – use 2 to skip header row
var namesValues = names.getRange(2, 2, 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);
}