Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>are you thinking of something <a href="https://script.google.com/macros/s/AKfycbx85RZuiw75MNA8v2eco50PGtpM7vSmXaGDT1XjXCmj39FP0501/exec" rel="nofollow">like this</a> ?</p> <p>The code is very simple, just add items to list 2 in a handler function triggered by list1</p> <p>Data are defined in a 2D array. Here is the full code of this small demo app.</p> <pre><code> var subItems = [['subCategory 1 of 1','subCategory 2 of 1','subCategory 3 of 1','subCategory 4 of 1'],['subCategory 1 of 2','subCategory 2 of 2','subCategory 3 of 2','subCategory 4 of 2'], ['subCategory 1 of 3','subCategory 2 of 3','subCategory 3 of 3']]; function doGet() { var app = UiApp.createApplication().setTitle('test listBox'); var panel = app.createHorizontalPanel().setStyleAttribute('padding','40px'); var sHdlr = app.createServerHandler('updatelist').addCallbackElement(panel); var items = ['category 1','category 2','category 3']; var list1 = app.createListBox().setName('list1').setId('list1').addChangeHandler(sHdlr); var list2 = app.createListBox().setName('list2').setId('list2').addItem(' . . . . . . . . .').setStyleAttribute('marginLeft','40px'); for(var i =0;i&lt;items.length;++i){list1.addItem(items[i],i)} panel.add(list1).add(list2); app.add(panel); return app; } function updatelist(e){ var app = UiApp.getActiveApplication(); var orig = e.parameter.source; if(orig=='list1'){ var listVal = Number(e.parameter[orig]); var list2 = app.getElementById('list2').clear(); for(var i =0;i&lt;subItems[listVal].length;++i){ list2.addItem(subItems[listVal][i],i); } }else{ //do something else } return app; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload