SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    copy text from one box to another

    Im trying to copy everythin that is written into textbox1 int otextbox2:

    Code:
    <%@ Page Language="C#" %>
    
    <!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 runat="server">
        <title>Untitled Page</title>
        <SCRIPT LANGUAGE="JavaScript">
            function SwapText() {
            var TextBox1 = document.getElementById('TextBox1');
            var Text = TextBox1.innerHTML;
            TextBox2.innerHTML = Text;
        }
        </SCRIPT>
    </head>
    <body>
        <form id="form1" runat="server">
            <input id="TextBox1" type="text" onkeyup="SwapText()" />
            <input id="TextBox2" type="text" />
            </form>
    </body>
    </html>
    ]

    Any ideas?

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.getElementById('TextBox2').value = document.getElementById('TextBox1').value;

    be happy

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <html
    <head>
        <title>Untitled Page</title>
        <SCRIPT>
            function SwapText(oForm)
    	{
    	        oForm.TextBox2.value = oForm.TextBox1.value;
    	}
        </SCRIPT>
    </head>
    <body>
        <form id="form1" runat="server">
            <input id="TextBox1" type="text" onkeyup="SwapText(this.form)" />
            <input id="TextBox2" type="text" />
            </form>
    </body>
    </html>

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Pepe, be happy!

  5. #5
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •