Poroh
Poroh

Reputation: 3

problems with setting parameters query objects

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

Answers (2)

Srik
Srik

Reputation: 7965

Add

return app; 

at the end of your respondToSubmit function

Upvotes: 2

Serge insas
Serge insas

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

Related Questions