If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to combine text from textareas into one textarea

Hello. I'm new around here. Sorry if this is an obvious newbie question =).

Problem = I have an HTML form that has 2 text areas. What I want to do is simply take the text entered into textarea1 and textarea2, combine the strings, and output the new string into textarea3. My situation is more complicated than this, but this is the part I cannot figure out how to do. Do I need JavaScript to do this? Sorry for the newb question. I tried Googling and searching w/in this site, but I haven’t found my answer. Thanks.

<html><head><meta http-equiv="Content-Language" content="en-us"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Release Note Builder</title></head><body><h1>Combine strings</h1><br/><form><textarea name="textarea1" cols="60" rows="5">
[textarea1's text]
</textarea><br></form><form><textarea name="textarea2" cols="60" rows="5">
[textarea2's text]
</textarea><br></form><form><textarea name="textarea3" cols="60" rows="5">
// I want to combine whatever is entered in textarea1 and textarea2, and auto-populate the text here.
// ex – if user entered “My car ran out of gas.” in textarea1, and entered “I had to push it off the road.” in textarea2, I want textarea3’s default text to be “My car ran out of gas. I had to push it off the road.”
</textarea><br></form></body></html>

Extremely basic solution? Give the textareas id's matching the corresponding names. Assuming you want to have this occur with the press of a button, use the onclick property of the button to run a very short script:

Keep in mind that "name" is not used in the same ways as "id". Id is used in situations where you want to seperate each element so each is idenified and referenced using a seperate id. Name can be used in the same way but was created more to refer to groups of form elements. You can actually name several inputs the same thing and refer to them using the array (HTML collection, actually) document.getElementsByName().

In conclusion, you can do it the way you did n his situation, but you find yourself in a situation where you need to refer both to an individual item or a group of items.

Keep in mind that "name" is not used in the same ways as "id". Id is used in situations where you want to seperate each element so each is idenified and referenced using a seperate id. Name can be used in the same way but was created more to refer to groups of form elements. You can actually name several inputs the same thing and refer to them using the array (HTML collection, actually) document.getElementsByName().

In conclusion, you can do it the way you did n his situation, but you find yourself in a situation where you need to refer both to an individual item or a group of items.

Cool, that makes sense (had to read it twice though =P). Thanks for the info.