Reputation: 3
Why app.getElementById('myTextBox').setValue('default')
work in showDialog()
but didnt work in respondToSubmit(e)
?
function showDialog() {
var app = UiApp.createApplication();
var panel = app.createVerticalPanel();
var textBox = app.createTextBox();
textBox.setName('myTextBox').setId('myTextBox');
app.getElementById('myTextBox').setValue('default');
var button = app.createButton(Modify');
panel.add(textBox);
panel.add(button);
var clickHandler = app.createServerClickHandler("respondToSubmit");
button.addClickHandler(clickHandler);
clickHandler.addCallbackElement(panel);
app.add(panel);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
function respondToSubmit(e) {
var app = UiApp.getActiveApplication();
app.getElementById('myTextBox').setText('Modifed');
}
Upvotes: 0
Views: 262
Reputation: 46822
in one case you use setText(), in the other you use setValue() ... didn't you notice ?
Also, when you are in the same function where you create an element you don't need to use getElementById()
you can just use textBox.setValue()
since textBox is the variable that holds the element- the getElementById
is only used to recall an element from another function.
Upvotes: 0