This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to copy a textbox answer to a textarea using javascript

 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm facing a problem here. I want to copy the answer in a textbox to a textarea using a javascript function.
 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can do this by first obtaining the id's of the textbox and textarea tags and then assigning the value attribute of the textarea to the text box. Please see the script below:

--------------------------------------------

function transfer(){
document.getElementById("text1").value=document.getElementById("textarea1").value

}
<input type="text" id="text1" name="textbox" value="Textbox"/><p>
<textarea id="textarea1">TextArea here!!! </textarea>
<button onclck="transfer()">Submit</button>


-----------------------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic