I created Browser.inputBox
which accepts only a single text. However I need to make a drop down list where I can choose from the list instead of typing the string myself.
A screenshot of the inputBox I created on clicking Odoo (in menu bar)>Settings:
Here is the function that is being triggered:
function menu_settings(params) {
if (!params){
params = [["url", "URL"], ["dbname", "Database Name"], ["username", "username"], ["password", "password"]];
}
for (var i = 0; i < params.length; i++){
var input = Browser.inputBox("Server Settings", params[i][1], Browser.Buttons.OK_CANCEL);
if (input === "cancel"){
break;
}
else{
ScriptProperties.setProperty(params[i][0], input);
}
}
}
Basically instead of typing the text, I need a drop list with predefined values.
I was checking the Browser class and I saw there is no such drop down list option. Most solutions that I have seen use DataValidation from texts input in the cells. But I want to give the list for the dropdown in my code and nothing on the spreadsheet.
How do I implement this?
This is the code to open an HTML dialog:
function fncOpenMyDialog() {
//Open a dialog
var htmlDlg = HtmlService.createHtmlOutputFromFile('HTML_myHtml')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(200)
.setHeight(150);
SpreadsheetApp.getUi()
.showModalDialog(htmlDlg, 'A Title Goes Here');
};
You need an HTML file.
<select name="nameYouWant">
<option value="something">Text</option>
<option value="anything">Drop Down Selection</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>