Reputation: 77
I tried solution at I am trying to pass a variable from my Google Script through to HtmlOutputFromFile, but can't get it working. I get error (translated from Dutch): "TypeError: Can't find function createHtmlTemplateFromFile in object HtmlService.
function fncOpenMyDialog() {
//Open a dialog
var htmlDlg = HtmlService.createHtmlTemplateFromFile('DropDown_NewCompetitionFile');
htmlDlg.myVar = "November";
htmlDlg = htmlDlg.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(200)
.setHeight(150);
SpreadsheetApp.getUi()
.showModalDialog(htmlDlg, 'A Title Goes Here');
};
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<select name="nameYouWant">
<option value="something">Text</option>
<option value="anything">Drop Down Selection</option>
<option value="anotherthing"><?myVar?></option>
</select>
<hr/>
<ul>
<li>This is a list.</li>
<li>This is line two.</li>
</ul>
<button onmouseup="closeDia()">Close</button>
<script>
window.closeDia = function() {
google.script.host.close();
};
</script>
</body>
</html>
Upvotes: 0
Views: 254
Reputation: 64042
You can do things any way you wish but this seems a lot simpler:
<input type="button" value="Close" onClick="google.script.host.close()" />
than this:
<button onmouseup="closeDia()">Close</button>
<script>
window.closeDia = function() {
google.script.host.close();
};
</script>
and I prefer to load my select options via javascript on window.onload
Upvotes: 0
Reputation: 11268
Replace
HtmlService.createHtmlTemplateFromFile
with
HtmlService.createTemplateFromFile
Upvotes: 1