Enhancing the Order form

To enhance the Order form, update the doGet function as follows:

function doGet(){
  var template = HtmlService.createTemplateFromFile("Order");
  template.pricelist = getPrice();

  var html = template.evaluate();
  return HtmlService.createHtmlOutput(html);
}

The price list is assigned to the template as a 2-dimensional array and is returned by the function shown here:

function getPrice(){
  var data = SheetStock.getDataRange().getValues();
  
  // remove header row.
  data.shift();

  return data;
}

In the Order.html file, update the select tag markup as shown in this code snippet:

<td> <select id="item" name="item"> <? for(var i in pricelist){ ?> <option value="<?= pricelist[i][0] ?>" > <?= pricelist[i][0] ?></option> <? } ?> </select> </td> ...

Get Learning Google Apps Script now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.