Java Script


JavaScript Tutorial


Admission Enquiry Form


How to shift name from first textbox to second textbox by clicking button?

Example :

<html>
<head>
<title>Show name of first textbox in second textbox</title>
<script>
function shift_name()
{
var firstbox=document.getElementById("txt_firstbox");
var secondbox=document.getElementById("txt_secondbox");

secondbox.value=firstbox.value;
firstbox.value="";

}
</script>
</head>
<body>
<form>
<table>
<tr><td><label>Enter Name:</label></td>&nbsp;<td><input type="text" id="txt_firstbox"></td></tr>
<tr><td><label>Get Name:</label></td>&nbsp;<td><input type="text" id="txt_secondbox"></td></tr>
<tr><td><input type="button" value="click" onClick="shift_name()"></td></tr>
</table>
</form>
</body>
</html>

Output:

Show name of first textbox in second textbox