How to copy textbox values to another textbox using java script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 43%;
        }
        .style2
        {
            width: 184px;
        }
    </style>
    <%--here we create a javascript funcation for copy the values from one textbox to another textbox.--%>
    <script type="text/javascript">

        function Copy() {
            var txtmain = document.getElementById('txtmain');
            var txtcopy = document.getElementById('txtcopy');
            txtcopy.value = txtmain.value;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="style1" align="center">
            <tr>
                <td class="style2">
                    Name
                </td>
                <td>
                    <asp:TextBox ID="txtmain" runat="server" onblur="Copy()" Height="25px" Width="209px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    copy into this textbox
                </td>
                <td>
                    <asp:TextBox ID="txtcopy" runat="server" Height="25px" Width="209px" ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>



Out-put:-
How to copy textbox values to another textbox using java script How to copy textbox values to another textbox using java script Reviewed by NEERAJ SRIVASTAVA on 11:13:00 AM Rating: 5

No comments:

Powered by Blogger.