Written by Malappa Kuruva on August 20, 2014 in JavaScript

Copy Text from Textbox with Button Click [JavaScript]

GET ALERTS:

Get our Latest updates delivered to your mailbox!

We are back with yet another programming tutorial.

This is a beginner’s Javascript code, that you have to try if you’ve started learning JavaScript lately. In this program, we will create two text boxes and a button, in which whatever you enter on to the first textbox will be copied onto the second textbox if you click on the button. Sounds fair?

These kind of applications appears really basic, but we’ll be using these applications while designing the text editors a lot. You can consider it as a basic practical Javascript application.

So, lets check out how this code works.

Download Source Code

<html>
<head>
<title>
Copy text</title>
</head>
<body>
<center>
<h2>Copy text from different field</h2>
<p>
<input type="text" style="color: #FE0080;background-color: #B9C299" id="sorcefiled" value="Hai
Hello">
<input type="text" style="color: #FE0080;background-color: #B9C299" id="targetfiled">
<button style="background-color: #E799A3" onclick="document.getElementById('targetfiled').value =
document.getElementById('sorcefiled').value">Click to Copy Text
</p>
</center>
</body>
</html>

Output:

input

 

 

output image

{ 1 comment… read it below or add one }

professional hair December 9, 2016 at 9:26 am

Great article! This is the kind of info that are supposed to be shared around the internet.
Disgtrace on the search engines for now not positioning this post higher!
Come on over and talkk over with my website . Thanks =)

Reply

Leave a Comment

Previous post:

Next post: