My project is on Google Apps Script. I’ve been working on writing an html dialogue for a dropdown menu. I was having issues with getting my secondary function to run, and I’ve whittled down the issue with google.script.run.
When I run function custdialogue, the menu pops up as expected, and I get the alert with the selected value as expected. On my executions tab, I can see each instance of custdialogue that I test, but no executions for logval.
Is this a formatting error?
JS:
function custdialogue() {
const htmlDlg = HtmlService.createHtmlOutputFromFile('Filename')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(200)
.setHeight(150);
const ui =SpreadsheetApp.getUi()
ui.showModalDialog(htmlDlg, 'Title');
};
function logval() {
console.log("value")
}
HTML:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<label for="option-list">Pick an option:</label>
<select option="option-list" id="option-list">
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
<button id="button" onclick="submitval()">Click</button>
<input type="submit" id="button" value="close" onclick="closeIt()"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
function submitval(){
var entry = $(document.getElementById('option-list')).val()
alert(entry)
closeIt()
}
function closeIt(){
google.script.host.close()
}
googe.script.run.withSuccessHandler(submitval)
.logval();
</script>
</body>
</html>
Currently, I am expecting to see an execution for custdialogue and an execution for logval. Upon opening the execution for logval, I would see that the console logged "Value".
When I run this function, I only see an execution for custdialogue
2
Answers
It appears you have a typo in your code.
Replace
With
Try it this way:
gs:
html: