View Full Version : Pulling info from textbox and putting it in textarea

Mar 19th, 2010, 07:13 PM
I am not 100% sure if this an html question, but I was wondering how I would get the information a user inputs into a textbox and display it in textarea. The user would hit an "enter" button after inputting the data into the textbox and then the data would appear in the textarea.

Mar 20th, 2010, 04:09 PM
The following should do what you want.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html lang='en'>
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'>
<title>Text to Textarea</title>
<h1>Text to Textarea</h1>
<p>Hit the "enter" button after inputting data into the textbox
and then the data will appear in the textarea.</p>
<p><label>Textbox: <input id="text"></label>
<input type="submit" value="enter"
onclick="getElementById('ta').innerHTML = getElementById('text').value"></p>
<textarea id="ta" rows="2" cols="30"></textarea>

The heavy lifting is done in the submit input tag with onclick="getElementById('ta').innerHTML = getElementById('text').value".