Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  101] [ 2]  / answers: 1 / hits: 26414  / 9 Years ago, wed, march 4, 2015, 12:00:00

Say I have this text box:



<input type=text id=myText placeholder=Enter Name Here>


Upon pressing a button, I would like to send the value entered into this div:



<div id=text2></div>


I'm not entirely sure how to do this. Do I create a function and call it to the div? How would I do that?



Could someone clear this up for me? Thanks.


More From » html

 Answers
9

Add an onclick to your button:



<input type=button id=somebutton onclick=addText()>


Then write the javascript:



function addText()
{
document.getElementById('text2').innerHTML = document.getElementById('myText').value;
}

[#67582] Sunday, March 1, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
julissaimana

Total Points: 593
Total Questions: 108
Total Answers: 112

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
julissaimana questions
Thu, Jun 11, 20, 00:00, 4 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
Thu, Mar 26, 20, 00:00, 4 Years ago
;