Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to copy a textbox answer to a textarea using javascript  RSS feed

 
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
Boost this thread!