I am trying to generate a selector that populates with various tasks based on a previous selector. I have seen the short way to do it with if/else if block code, however for each of my selections I have 20+ options that could be chosen.
I have tried to put options on various sheets within the spread sheet and run a if/else if statement so the drop down will populate with tasks that are from one of the sheets associated with a selection option.
<!--my selection i want to base the next selection options off of-->
<select id = 'reason'>
<option value="" disabled selected>Choose Reason</option>
<option value = 'prec'>PREC</option>
<option value = 'crh'>CRH</option>
<option value = 'bh'>BH</option>
<option value = 'ih'>IH</option>
<option value = 'rh'>RH</option>
</select>
<Label>Call Reason</Label>
</div>
<!-- function that generates tasks dynamically from a sheet -->
function getTasks(){
var ss= SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName('PREC');
var list = ws.getRange(1,1).getDataRegion().getValues();
var options = {};
list.forEach(function(v){
options[v[0]]= null;
});
<!--essentially If someone chose "CRH" I would want it to open the sheet
with the CRH options -->
The way I wrote the loop didn't work.
function getTasks(){
var ss= SpreadsheetApp.openByUrl(url);
var options = {};
//basically added else ifs for each reason with the same code just dif
//sheet names
if (document.getElementById('reason')='prec'){
var ws = ss.getSheetByName('PREC');
var list = ws.getRange(1,1).getDataRegion().getValues();
list.forEach(function(v){
options[v[0]]= null;
}
});
return options
}