Help with add text to text box button | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help with add text to text box button

Is it possible to add specified text in textbox (adding text only not replacing already existing text) textbox is in html form format. The specific text to be added is few lines only. If it's possible can you please show me how? If possible plz use javascript. Thank you in advance.

19th Mar 2019, 6:31 AM
Himanshu
Himanshu - avatar
4 Answers
+ 4
//Here is a code <body> <input type="text" id="test"> <button onClick="add()">add text</button> </body> <script> function add(){ document.getElementById("test").value="hello " } </script>
19th Mar 2019, 9:45 AM
Sudarshan Rai
Sudarshan Rai - avatar
0
Thanks buddy I will try it in my code
19th Mar 2019, 10:44 AM
Himanshu
Himanshu - avatar
0
Problem with the code is it replaces text not adding text to existing one. any solution for this?
19th Mar 2019, 3:33 PM
Himanshu
Himanshu - avatar
0
Never mind I solved it
19th Mar 2019, 3:52 PM
Himanshu
Himanshu - avatar