I checked the similar question already on here but it didn’t help.
It’s my clickFunc() that doesn’t seem to get executed here:
HTML:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form id="myForm">
<select id="players" name="players">
<option value="Kobe">Kobe</option>
<option value="LeBron">LeBron</option>
<option value="Jordan">Jordan</option>
</select>
<br><br>
<input type="button" value="OK" onclick="submitForm()">
</form>
</body>
<script>
function onSuccess() {
alert("onSuccess");
}
function submitForm() {
let player = document.getElementById('players').value;
google.script.run.withSuccessHandler(onSuccess).clickFunc();
}
</script>
</html>
GAS:
function testFunc() {
const ui = SpreadsheetApp.getUi();
const htmlOutput = HtmlService.createHtmlOutputFromFile('dropdownTest')
.setWidth(300)
.setHeight(200);
const dialog = ui.showModalDialog(htmlOutput, "Push the button")
Logger.log("TEST");
}
function clickFunc() {
Logger.log("test")
}
The dialog does get displayed. I select a player then click on the “OK” button. onClick() doesn’t seem to work, but the callback function onSuccess() does.