SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    duplicate text to a form field real time

    ive done a search, but I couldnt find anything.. hopefully someone here can help me.

    Does anyone know how to make it so that whatever you type in one form field gets duplicated real time to another form field on the same page?

  2. #2
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi the311guy,
    Code:
    function duplicate()
    {
       var f1 = document.getElementById('field1');
       var f2 = document.getElementById('field2');
    
       f2.value = f1.value;
    }
    HTML Code:
    <input type="text" id="field1" onchange="duplicate()" />
    <input type="text" id="field2" />
    Untested, but should work fine.

    Regards,
    Jordan

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow thanks for the fast response, that works great!!

    do you know of a way to make it appear as you type instead of when you click away?

  4. #4
    SitePoint Evangelist stef25's Avatar
    Join Date
    Nov 2004
    Location
    belgium
    Posts
    465
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try replacing onchange with onkeypress
    I need someone to protect me from
    all the measures they take in order to protect me


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
  •