Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Posts
    600
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Automatically Populating One Field With Another?

    Hey Guys,

    Question - I've got a form with these 2 fields: "for" and "ship to". When the user enters data for the "for" field (something like this):

    Name of Company
    Address of Company
    City, State, Zip

    After they tab onto the next field, how can I get that data to automatically populate in the "ship to" box? Currently both of these fields are textareas.

    Thanks much.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Something like this?:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    </
    head>
    <
    body>
    <
    form>
    <
    textarea name="t1" cols="30" rows="3" onkeyup="this.form.elements['t2'].value=this.value"></textarea>
    <
    textarea name="t2" cols="30" rows="3"></textarea>
    </
    form>
    </
    body>
    </
    html
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Posts
    600
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Nice .. . I just came up with:

    // copies forField into shipTo field
    function ForToShipTo() {
    var val3 = document.myForm.forField.value;
    document.myForm.shipTo.value = val3;
    }

    <textarea name="forField" class="textbox" rows="5" cols="60" onblur="ForToShipTo()"></textarea>
    <textarea name="shipTo" class="textbox" rows="5" cols="70"></textarea>

    Same thing it looks like, only yours does it on the fly.

    Thanks for the help.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I often try to avoid direct (name,id) referenceing by using either this self reference (with variants this.form, this.value, this.parentNode, this.getElementsByTagName(tagname)[index] ... and so on). It makes the code more useful and dynamic...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Regular Coder
    Join Date
    Jul 2003
    Posts
    600
    Thanks
    17
    Thanked 0 Times in 0 Posts
    True .. that would be helpful with my next issue.

    Calculating Multiple Totals (via a function)

    Any ideas?

    Thanks.


  •  

    Posting Permissions

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