I created a button in Google Spreadsheet. When I push the button a custom window appears. In that window I have two buttons, one to close and one to see a new window. Everything goes well except the second button, to view a new window. I already programmed this. The button with value oefening 1 doesn't work. I want to see a new panel. When I test the function: oefeningshow() it is correct! Can you please help me?
<form>
<p><label id="naam"> </label> uit <label id="klas"></label> </p>
<input type="button" value="oefening 1" onclick="oefeningshow()" />
<input type="button" value="Close Sidebar" click="google.script.host.close()" />
</form>
<script>
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Dialog')
.addItem('Open', 'openDialog')
.addToUi();
}
function oefeningshow() {
var html = HtmlService.createHtmlOutputFromFile('oefening1')
.setSandboxMode(HtmlService.SandboxMode.IFRAME).setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, 'oefening1');
}
Best Answer
Having an HTML service element call a function in your script requires the use of the google.script.run API
changing:
to
should result in the correct behavior.
the method the OP described in a comment goes against the documentation for google.script.host and may not continue to work.