SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Threaded View

  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up autofill address problem

    I found this great script to auto fill a ship address based on the bill address

    Code:
    <script type="text/javascript" language="javascript">
    function set_billing(box)
    {
    var f = box.form, b_which = box.checked, from_el, to_el, i = 0;
    var fld_name = new Array('city' , 'state');
    while (from_el = f[fld_name[i]])
    {
    to_el = f['bill' fld_name[i ]];
    to_el.value = b_which ? from_el.value : '';
    if (to_el.readOnly != null)
    to_el.readOnly = b_which ? true : false;
    else to_el.onfocus = b_which ? function() {this.blur();
    }
    : null;
    }
    }
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td align="right">
    <strong>Mailing Address</strong><br>
    City: <input name="city" type="text" id="city" onchange="set_billing(billingaddrsame)"><br>
    State: <input name="state" type="text" id="state" onchange="set_billing(billingaddrsame)"><br>
    <strong>Billing Address</strong><br>
    ( same as above)
    <input type="checkbox" name="billingaddrsame" onclick="set_billing(this)"><br>
    City: <input name="billcity" type="text" id="billcity"><br>
    State: <input name="billstate" type="text" id="billstate"><br>
    </td>
    </tr>
    </table>
    </form>
    see it in action here http://newsourcemedia.com/Tutorials/...ressCkBox.html


    The problem I have come across is in using a dropdown list for the state. I am not able to autofill a select box from bill address to ship address. Can someone help me out with this on?

    Thanks!!
    Last edited by dude9er; Jul 13, 2007 at 15:29.


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
  •