Geme
Geme

Reputation: 447

Javascript: add a text into text area

I would like to load a text into text area, when clicked in a map area. When I click in the second area, I would like to add another (different) text

How can I make this happen?

http://jsfiddle.net/CQvKJ/

Upvotes: 1

Views: 954

Answers (2)

Smamatti
Smamatti

Reputation: 3931

I don't know Mootools, so I did this in JS only without framework. This may not be a good solution, but this is basically what you want to do, no matter how you append the text.

Sample

http://jsfiddle.net/CQvKJ/2/

Updated JS

function funzione1() {
    // alert("add text : 1.");
    var e = document.getElementById('my_text');
    e.value += "1";
}

function funzione2() {
    // alert("add text: 2");
    var e = document.getElementById('my_text');
    e.value += "2";
}

Upvotes: 2

Dave Newton
Dave Newton

Reputation: 160170

  1. Identify the <textarea> by id.
  2. Retrieve the element in the click handlers.
  3. Set the element's value to the text you want to show up.

Forked fiddle.

Upvotes: 1

Related Questions