PDA

View Full Version : <textarea>


primadog
07-19-2002, 01:23 AM
how do i modify the content inside <textarea> using javascript?

mordred
07-19-2002, 01:31 AM
Please elaborate on "modify".

In general, you access a textarea just as any other form element. If your form is named "ernie" and the textarea is named "bert", you can insert new content into it by using these equivalent code snippets:

document.bert.ernie.value = "zappazappa";
document.forms[0].elements[0].value = "zappazappa"; // assumes that it's the only form with the first input field
document.forms["bert"].elements["ernie"].value = "zappazappa";

Benahimvp
07-19-2002, 04:01 AM
This will store a whole new value into the <textarea>. If you want to still keep some or all of the information in it, then you'll have to store the value of the <textarea> first and then manipulate that string.