Results 1 to 6 of 6

Thread: textboxes

  1. #1
    Join Date
    Oct 2008
    Location
    my desk
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default textboxes

    How could I take text from one textbox and put it into another textbox? Can anyone tell me how to do this by pressing a button?

    Thank you in advance.

    ===

    The distant cousin of c++,
    a++

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Heh, whoa!! Taking text from one text box and putting it into another text box? Here is some code:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function add(t,u)
    {
    document.getElementById(u).value = document.getElementById(t).value;
    }
    </script>
    </head>
    <body>
    <input type="text" id="t1"><br /><input type="text" id="t2"><br /><input type="button" value="Add" onclick="add('t1','t2');">
    </body>
    </html>

  3. The Following User Says Thank You to magicyte For This Useful Post:

    a++ (10-10-2008)

  4. #3
    Join Date
    Oct 2008
    Location
    my desk
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Oh, wow! Thanks for that quick reply! It works great!

    Much thanks!

    ===

    The distant cousin of c++,
    a++

  5. #4
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Ah. Don't mention it.

    -magicyte

  6. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Here is some better code:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head>
        <title>Page Sans Titre</title>
      </head>
      <body>
        <form action="/server/side/equivalent"
              onsubmit="return (this.elements.text1.value = this.elements.text2.value), false;">
          <div>
            <textarea name="text1">Foo</textarea>
            <textarea name="text2">Bar</textarea>
            <input type="submit" value="Copy">
          </div>
        </form>
      </body>
    </html>
    magicyte, never forget your validation, and stay away from the pseudo-XHTML and presentational markup.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. The Following User Says Thank You to Twey For This Useful Post:

    a++ (10-10-2008)

  8. #6
    Join Date
    Oct 2008
    Location
    my desk
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the code, Twey!!

    ===

    The distant cousin of c++,
    a++

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
  •