4

I know this has to be be doable, does anyone know how and if you can do it?

1
  • 2
    Are you trying to insert the value into the textarea after the existing content? Commented Dec 15, 2010 at 20:48

4 Answers 4

7

or you can do it this way:

var myVar = 'sup fresh our turn baby!';
var myTextArea = document.getElementById('myArea');
myTextArea.innerHTML += myVar;
Sign up to request clarification or add additional context in comments.

1 Comment

woot woot? then someone might call me a nerd :/
3

Something like this should work:

var textArea = document.getElementById("mytextarea"); // assuming there is a textarea with id = mytextarea
var textToAppend = document.createTextNode("Hello, World!");
textArea.appendChild(textToAppend);

EDIT: or, as Pointy suggested, the last two lines can be replaced by:

textArea.value += "Hello, World!";

1 Comment

Why not just textArea.value += textToAppend; ??
2
function appendText(str) {
var obj=document.getElementById("myTextArea")
var txt=document.createTextNode("append this text")
obj.appendChild(txt)
}

1 Comment

Same question to you as I asked @GreginYEG: why not just append to the "value" attribute of the <textarea> ?? Why go to the expense of creating a node (slow in IE)?
1

Gee whiz guys:

document.getElementById('whatever').value += someJavascriptString;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.