Reputation: 21
How can I get text from textarea or textbox.
function myClickHandler() {
var app = UiApp.getActiveApplication();
var textbox = app.getElementById("TextBox1");
var text = textbox.text;
textbox.setText(text + "1");
return app;
}
After run of this function is in my textarea: "undefined1".
On googledevelopers help page https://developers.google.com/apps-script/class_textbox is not getText method.
How can I get text from textbox?
Upvotes: 1
Views: 972
Reputation: 12673
In order to pass a widget's value to a callback handler you must do two things:
texbox.setName('foo');
clickHandler.addCallbackElement(textbox);
If you've done that, then the value of the textbox will be passed in the event parameter of your callback function.
function myClickHandler(event) {
var textboxValue = event.parameters['foo'];
...
}
Upvotes: 0
Reputation: 21
It's not textbox.text
. It should be textbox.value
.
function myClickHandler() {
var app = UiApp.getActiveApplication();
var textbox = app.getElementById("TextBox1");
var text = textbox.value;
textbox.setText(text + "1");
return app;
}
Upvotes: 2