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>
The drop-down items will reflect whatever is included or updated in the Stock
Sheet. The default item will be the top-most or the first item in the list...