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 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    state field for copying shipping same as billing not working

    Hello all,

    I am trying to copy the billing information to be the same as the shipping information when they select the checkbox. Everything seems to work except for the State field which is a drop down. Depending on what country they select, the state field will automatically populate.

    Does anyone know how I can copy the billing state to be the same as shipping as well?

    Text file attached.

    Thanks in advance.
    Attached Files Attached Files

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    You could do it by sending an event to the country field in the shipping part of the form to cause it to then change the state in shipping, but I think an easier way would be to just disable *both* the country and state fields in shipping and then *ADD* two <input type=text> fields with country and state that match billing.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    Looked at your code after answering.

    You already have all the code you need to make this easy!

    Just add one line.

    Let's do it this way:
    Code:
    function copyForm(form) 
    {
       if (form.copy.checked) 
       {
            InitSaveVariables(form);
            form.Bill_To_Company.value = form.Ship_To_Company.value;
            form.Bill_To_Contact_Name.value = form.Ship_To_Contact_Name.value;
            form.Bill_To_Department.value = form.Ship_To_Department.value;        
            form.Bill_To_Address_1.value = form.Ship_To_Address_1.value;
            form.Bill_To_Country.selectedIndex = form.Ship_To_Country.selectedIndex;
            changeBillStates( );
            form.Bill_To_City.value = form.Ship_To_City.value;
            form.Bill_To_State.selectedIndex = form.Ship_To_State.selectedIndex;
            form.Bill_To_Zip.value = form.Ship_To_Zip.value;
            form.Bill_To_Phone.value = form.Ship_To_Phone.value;
    } ... rest same ...
    Line in red is added.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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