Wednesday, October 28, 2009

JavaScript : Onclick Event - Copy text

The text in the first input field will be copied to the second input field when a button is clicked:

Demo :
Click the button to copy the content of Field1 to Field2.

Field1:
Field2:


Sample Code :
Click the button below to copy the content of Field1 to Field2.
<br />
Field1: <input type="text" id="field1" value="Hello World!">
Field2: <input type="text" id="field2">
<button onclick="document.getElementById('field2').value=
document.getElementById('field1').value">Copy Text</button>

No comments:

Post a Comment