// forked from https://gist.github.com/mhawksey/1276293 // function to recieve the data from the form function doPost(e) { // get the correct spreadsheet var ss = SpreadsheetApp.openById(ScriptProperties.getProperty('active')); // get the sheet with a name of "DATA" var sheet = ss.getSheetByName("DATA"); // find the headers of the sheet and their values var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]; // get the row below the headers var nextRow = sheet.getLastRow(); // get the first cell var cell = sheet.getRange('a1'); // the first column in the sheet var col = 0; // insert the data into the spreadsheet in a loop only if the header is the same as the html name="" for (i in headers){ if (headers[i] == "Timestamp"){ val = new Date(); } else { val = e.parameter[headers[i]]; } cell.offset(nextRow, col).setValue(val); col++; } // debugging var app = UiApp.createApplication(); var panel = app.createVerticalPanel(); for(p in e.parameters){ panel.add(app.createLabel(p +" "+e.parameters[p])); } app.add(panel); return app; } // function to init the spreadsheet for the first time function setUp() { ScriptProperties.setProperty('active', SpreadsheetApp.getActiveSpreadsheet().getId()); }