google apps script - How to enable or disable textbox and button from listbox selection -


i trying use validation feature enable or disable textbox , button when listbox value selected. please see example code below. appreciated.

function examplelistbox(){ var app = uiapp.createapplication().settitle('example').setheight(100).setwidth(250); var ss = spreadsheetapp.getactivespreadsheet(); var panel = app.createformpanel(); var grid = app.creategrid(5, 3); var listbox = app.createlistbox().setid('lb1').additem('none').additem('item1').additem('item2').additem('item3').additem('item4'); var textbox = app.createtextbox().setid('tb1').settext('none').setenabled(false); var pressme = app.createbutton('press me').setid('btn1').setenabled(false);  var chandler1 = app.createclienthandler() .validatematches(listbox, 'item1, item3') .fortargets(textbox).setenabled(true) .validatenotmatches(listbox, 'none, item1, item4') .fortargets(textbox).setenabled(false);  grid.setwidget(0, 0, listbox) .setwidget(0, 1, textbox).addclickhandler(chandler1) .setwidget(1, 1, pressme);  app.add(grid) app.add(panel)  ss.show(app); } 

i think have add client handler list or whole grid instead. also, can't combine both function in single client handlere, create 1 each desired effect (enable , disable)

and last, argument in validatematches method regular expression, not simple string concatenation if want condition true on "item1" or "item3" should use regex validates on these 2 values. here example code not work how should shows begining of right way ...

function examplelistbox(){ var app = uiapp.createapplication().settitle('example').setheight(100).setwidth(250); var ss = spreadsheetapp.getactivespreadsheet(); var panel = app.createformpanel(); var grid = app.creategrid(5, 3); var listbox = app.createlistbox().setid('lb1').additem('none').additem('item1').additem('item2').additem('item3').additem('item4'); var textbox = app.createtextbox().setid('tb1').settext('none').setenabled(false); var pressme = app.createbutton('press me').setid('btn1').setenabled(false);  var chandler1 = app.createclienthandler() .validatematches(listbox, 'item1') .fortargets(textbox,pressme).setenabled(true); var chandler2 = app.createclienthandler() .validatematches(listbox, 'none') .fortargets(textbox,pressme).setenabled(false);    grid.addclickhandler(chandler1).addclickhandler(chandler2) grid.setwidget(0, 0, listbox) .setwidget(0, 1, textbox) .setwidget(1, 1, pressme);  app.add(grid) app.add(panel)  ss.show(app); } 

i'm not enough @ regex implement multi-condition in validatematches i'm sure find somewhere. if not, ask on javascript tag, these guys amazing ^^


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -