I have a custom Dropdown menu in Google Sheets. I'd like to pass information from a sheet into the dropdown. (see the screenshot for data)
After updating my code thanks to @Cooper, and running the displayDropdown function, I am successfully logging the data. So it IS reading the data... But, it is not being populated in the dropdown. What (obvious) step am I missing here?!
myDropdown.html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form>
<div class="select-style">
<select id="dropJob">
<?!= getDays(); ?>
</select>
</div>
</form>
</body>
</html>
Code.gs:
function displayDropdown()
{
var htmlDlg = HtmlService.createHtmlOutputFromFile('myDropdown')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(350)
.setHeight(250);
SpreadsheetApp.getUi()
.showModalDialog(htmlDlg, "title");
return HtmlService.createTemplateFromFile('myDropdown').evaluate();
}
function getDays()
{
var ui = SpreadsheetApp.getUi();
var active = SpreadsheetApp.getActive();
var sheet = active.getSheetByName("Days");
var myRange = sheet.getRange("A1:A7");
var data = myRange.getValues();
var optionsHTML = "";
for (var i = 0; i < data.length; i++) {
optionsHTML += '<option>' + data[i][0] + '</option>';
};
Logger.log(optionsHTML);
return optionsHTML;