Forum OpenACS Q&A: HtmlArea: Use Javascript to add text

Is it possible to write a value/text string to the HtmlArea using javascript?
My problem:
if a user selects a certain value from a drop-down list I want to populate the HtmlArea with some basic lines of text; but I cannot find any way to do this.
Thanks.
Collapse
Posted by Gustaf Neumann on
Checkout the InsertWord plugin for xinha. Xinha is one of the successors of htmlara, if you are lucky, this plugin works as well with htmlarea.

http://xinha.python-hosting.com/wiki/InsertWords

xinha is highly compatible to htmlarea 3, but has many bugs removed. It is committed to the oacs-5-2 branch. If you use xinha, you just have to enable the plugin... (see also xowiki thread)

Collapse
Posted by Paolino Paperino on
Thanks, Gustaf.
Collapse
Posted by Eric Ramone on
I used a very simple solution to workaround this problem:

Add to your htmlarea.js the following prototype:

// set the HMML
HTMLArea.prototype.setHTML = function() {
this._textArea.value = text;
};

Now, insert the text on the fly:
editor.setHTML('This is the new value');

The editor will be updated with the text.

Eric
2dev