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?
From the DATA tab, select Data Validation. Click Data Validation in the drop-down list. In the dialog box, select List from the Allow drop-down menu. In the source field, type the choices you'd like your drop down menu to include, separated by commas.
When an item (option) is selected in DropDownList (HTML SELECT), the EnableDisableTextBox JavaScript function is executed. Inside this function, based on whether the Other option (item) is selected, the TextBox will be enabled else disabled. The HTML Markup consists of a DropDownList (HTML SELECT) and a TextBox.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With