user2962151
user2962151

Reputation: 51

Google Apps Script: How to get text from textArea? (replaceText)

I need replace text in textArea, what am I doing wrong?

function doGet() {
  var app = UiApp.createApplication();
  var textArea = app.createTextArea()
  .setText('here is text... here is text... here is text...')
  .setName('theText').setId('theText')
  .addClickHandler(app.createServerHandler('processing'));
  app.add(textArea);
  return app;
}

function processing(e) {
  Logger.log(e.parameter.theText); // In Log I see: 'here is text... here is text... here is text...'
  var textIn = e.parameter.theText;
  var textOut = textIn.replaceText('/[text]/', 'new text'); // Here I get error: Unable to find a function replaseText in the object here is text... here is text... here is text....
  var app = UiApp.getActiveApplication();
  app.getElementById('theText').setText(textOut);
  return app;  
}

I tryed getText, getBody, editAsText etc. with 'e.parameter.theText' but with same result. Where is mistakes?

Upvotes: 0

Views: 824

Answers (1)

Serge insas
Serge insas

Reputation: 46802

The replace method is simply replace and not replaceText this is pure JavaScript. It seems that you are making a confusion between DocumentApp and Javascript string manipulation.

Upvotes: 1

Related Questions