Need JScript code to put same Textbox value in another Textbox (same page / same form)

Enflow used Ask the Experts™
Need simple JavaScript Solution to Put Same text box text values into another textbox on the same form and same page...

I have this working in runat with code and onkeypress call code BUT the postback re-positioning is irritating including trying to suppress it with maintain...

JScript should cause no post back i assume and be quite easy ?

<%@ Page Language="VB" AutoEventWireup="false" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data"%>\
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

    Private Sub MyTextBox_TextChanged(sender As Object, e As EventArgs) Handles MyTextBox.TextChanged
        AddTextBox.Text = MyTextBox.Text
    End Sub
<html lang="en" xmlns="">
<meta charset="utf-8" />
  <form id="form1" runat="server">
        <asp:TextBox ID="MyTextBox" runat="server" onkeypress="AddTextBox_TextChanged" AutoPostBack="true"></asp:TextBox>
        <asp:TextBox ID="AddTextBox" runat="server" Enabled="False" ReadOnly="True"></asp:TextBox>

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Technology Ninja
Distinguished Expert 2018
Hi Enflow,

Assuming you are not using Jquery

function copyValues()
document.getElementById("TARGET TEXTBOX's ID").value = document.getElementById("SOURCE TEXTBOX's ID").value;

Open in new window



Working Now ... Thanks...

Function JS code:

function matchSigs() {document.getElementById("AutoSN_1").value = document.getElementById("SN_1").value;}

Here is Source ASP.NET Textbox

<asp:TextBox ID="SN_1" runat="server" Height="25px" Width="340px" Wrap="False" BackColor="#EAF4FF" Font-Size="Large" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" ToolTip="Head of Household Types In Their Full Name Signature Here" onchange"javascript;matchSigs();"></asp:TextBox>

Here is TARGET ASP.NET Textbox

<asp:TextBox ID="AutoSN_1" runat="server" Height="25px" Width="270px" Wrap="False" BackColor="#F2F2F2" Font-Size="Large" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" ToolTip="Applicant's Signature Goes Here Automatically" Enabled="False" ReadOnly="True"></asp:TextBox>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial