copying contents of billing addy to shipping addy

Discussion in 'Javascript' started by libsfan01, Jun 16, 2006.

  1. libsfan01

    libsfan01 Guest

    Hi all!

    Can anyone show me how to use javascript to populate shipping address
    form fields with pre-typed payment address details upon checking of a
    checkbox next to the obligatory text "click here if the shipping
    address is the same as the billling address"? I've looked everywhere
    for it but surprizingly have had no luck!
    libsfan01, Jun 16, 2006
    #1
    1. Advertising

  2. libsfan01

    Dag Sunde Guest

    libsfan01 wrote:
    > Hi all!
    >
    > Can anyone show me how to use javascript to populate shipping address
    > form fields with pre-typed payment address details upon checking of a
    > checkbox next to the obligatory text "click here if the shipping
    > address is the same as the billling address"? I've looked everywhere
    > for it but surprizingly have had no luck!


    ....
    <input type="text" id="billingAddress" />
    ....
    <input type="text" id="shippingAddress" />
    ....

    <script>
    ....
    document.getElementById("shippingAddress").value =
    document.getElementById("billingAddress").value;
    ....
    </script>

    --
    Dag.
    Dag Sunde, Jun 16, 2006
    #2
    1. Advertising

  3. libsfan01

    Lee Guest

    libsfan01 said:
    >
    >Hi all!
    >
    >Can anyone show me how to use javascript to populate shipping address
    >form fields with pre-typed payment address details upon checking of a
    >checkbox next to the obligatory text "click here if the shipping
    >address is the same as the billling address"? I've looked everywhere
    >for it but surprizingly have had no luck!


    Find any of the existing forms that do this and look at the source.


    --
    Lee, Jun 16, 2006
    #3
  4. libsfan01

    libsfan01 Guest

    Hi Dag

    I've tried this and it doesn't work. Is something missing?

    "
    <head>
    <script type="text/javascript">
    document.getElementById("delforename").value =
    document.getElementById("forename").value;
    </script>
    </head>

    <body>
    <form action="" name="" id="form" method="post">
    <input type="text" id="forename" />
    <input type="text" id="delforename"/>
    <input type="submit" name="submit" value="submit" />
    </form>
    </body>

    </html>
    "


    Dag Sunde wrote:
    > libsfan01 wrote:
    > > Hi all!
    > >
    > > Can anyone show me how to use javascript to populate shipping address
    > > form fields with pre-typed payment address details upon checking of a
    > > checkbox next to the obligatory text "click here if the shipping
    > > address is the same as the billling address"? I've looked everywhere
    > > for it but surprizingly have had no luck!

    >
    > ...
    > <input type="text" id="billingAddress" />
    > ...
    > <input type="text" id="shippingAddress" />
    > ...
    >
    > <script>
    > ...
    > document.getElementById("shippingAddress").value =
    > document.getElementById("billingAddress").value;
    > ...
    > </script>
    >
    > --
    > Dag.
    libsfan01, Jun 16, 2006
    #4
  5. libsfan01

    Dag Sunde Guest

    libsfan01 wrote:
    > Hi Dag
    >
    > I've tried this and it doesn't work. Is something missing?
    >
    > "
    > <head>
    > <script type="text/javascript">
    > document.getElementById("delforename").value =
    > document.getElementById("forename").value;
    > </script>
    > </head>


    Script outside a function in the head section is run immediately,
    before your page is rendered. So while the sctipt statements is correct,
    there is noting on the page yet to copy to or from...

    >
    > <body>
    > <form action="" name="" id="form" method="post">
    > <input type="text" id="forename" />
    > <input type="text" id="delforename"/>
    > <input type="submit" name="submit" value="submit" />
    > </form>
    > </body>
    >
    > </html>
    > "


    Try this:

    <head>
    <script type="text/javascript">
    function copyAddress() {
    document.getElementById("delforename").value =
    document.getElementById("forename").value;
    }
    </script>
    </head>


    <body>
    <input name="chkCopy" type="checkbox" value="" onClick="copyAddress();">
    <label>Use billing adress</label>

    <form action="" name="" id="form" method="post">
    <input type="text" id="forename" />
    <input type="text" id="delforename"/>
    <input type="submit" name="submit" value="submit" />
    </form>
    </body>
    </html>

    --
    Dag.
    Dag Sunde, Jun 16, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denon
    Replies:
    0
    Views:
    411
    Denon
    Nov 8, 2003
  2. james
    Replies:
    1
    Views:
    340
    William Brogden
    Feb 8, 2004
  3. Big Bill

    munged amail addy or not?

    Big Bill, Dec 28, 2004, in forum: HTML
    Replies:
    3
    Views:
    461
    Wizard of Draws
    Dec 29, 2004
  4. linkswanted
    Replies:
    1
    Views:
    898
  5. opeirwp
    Replies:
    4
    Views:
    428
    Jonathan N. Little
    May 15, 2008
Loading...

Share This Page