Javascript examples for DOM Event:onclick
Click on a button to copy some text from an input field to another input field:
<!DOCTYPE html> <html> <body> Field1: <input type="text" id="field1" value="Hello World!"><br> Field2: <input type="text" id="field2"><br><br> <button onclick="myFunction()">Copy Text</button> <script> function myFunction() {//w ww . jav a 2 s . c o m document.getElementById("field2").value = document.getElementById("field1").value; } </script> </body> </html>