views:

113

answers:

3

How can I add custom text to already written text in textarea using javascript??Thanks...

A: 
myTextarea.value += "text to add to the textarea"
Eli Grey
A: 

Grab the existing text in the textarea (the element's .value)

Combine your existing text (append, prepend, insert, or whatever you need)

Write the result back to the textarea.

Tah-dah!

timdev
+2  A: 
function addText(elId,text) {
    document.getElementById(elId).value += text;
}

or:

function addText(elId,text) {
    var obj = document.getElementById(elId);
    var txt = document.createTextNode(text);
    obj.appendChild(txt);
}
karim79
elId is the id="" of the <textarea>....right
halocursed
Oh!I got it...Thanks
halocursed