title: Sum up numeric inputs in a Google Form
body: <p>SOF friends, </p>
  
  <p>I have a form which has a bunch of numeric fields among some date and string fields. </p>
  
  <p>How to add up the numeric values and include the total as a column in the spreadsheet where it saves the responses? Where do I write the script for this? At the form level or at the spreadsheet level? </p>
  
  <p>Here's what I have at this time, as a trigger on form submit which doesn't work: </p>
  
  <pre><code>function myFunction() {
    Logger.log("Spreadsheet: %s", SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName());
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getActiveSheet();
  
    //sheet.setActiveSelection("M1:M").clear();
    var range = sheet.getDataRange();
    var values = range.getValues();
    var lastrow = range.getLastRow(); 
    var lastcolumn = range.getLastColumn();
    Logger.log(lastrow);
    Logger.log(lastcolumn);
    Logger.log(values[lastrow][10]);
    var coll = values[lastrow][6];
    var drv = values[lastrow][7]; 
    var clnr = ((values[lastrow][8] != "")? values[lastrow][8]:0);
    var dsl = values[lastrow][10];
    var gen = values[lastrow][11];
    var tot = coll + drv + clnr + dsl + gen; 
    var singlecell = sheet.getRange(lastrow, 13);
    singlecell.setValue(tot);
    Logger.log(tot);
  }
  </code></pre>