Copy Billing and Shipping Address Fields Copy to Another

13,031

You have a typo in billng_first_name. You're missing the i.

Replace billng_ to billing_.

Share:
13,031
SNaRe
Author by

SNaRe

Updated on June 04, 2022

Comments

  • SNaRe
    SNaRe almost 2 years

    I am trying to copy shipping address into billing address with one click. As you can see here it works for an example that I found from a website : http://jsfiddle.net/aDNH7/

    My problem is when I implement code into my form, It doesn't work. I'm doing something wrong in somewhere but I'm not sure.

    My code is here . If you can help me to find the problem, i will appriciate that.

    <script>
    
        function FillBilling(f) {
    
            if(f.billingtoo.checked == true) {
    
                f.billing_first_name.value = f.first_name.value;
    
                f.billing_last_name.value = f.last_name.value;
    
                f.billing_address_1.value = f.address_1.value;
    
                f.billing_address_2.value = f.address_2.value;
    
                f.billing_city.value = f.city.value;
    
                f.billing_state.value = f.state.value;
    
                f.billing_zipcode.value = f.zipcode.value;
    
    
    
            }
    
            if(f.billingtoo.checked == false) {
    
                f.billing_first_name.value = '';
    
                f.billing_last_name.value = '';
    
                f.billing_address_1.value = '';
    
                f.billing_address_2.value = '';
    
                f.billing_city.value = '';
    
                f.billing_state.value = '';
    
                f.billing_zipcode.value = '';
    
            }
    
        }
    
    </script>
    
    <form action="http://www......" method="post" accept-charset="utf-8"><h1>SHIPPING ADDRESS</h1>
    
    <label for="first_name">First Name</label>
    
    <div><input type="text" name="first_name" id="first_name" value="" /></div>
    
    
    
    <label for="last_name">Last Name</label>
    
    <div><input type="text" name="last_name" id="last_name" value="" /></div>
    
    
    
    <label for="address_1">Address 1</label>
    
    <div><input type="text" name="address_1" id="address_1" value=""/></div>
    
    
    
    <label for="address_2">Address 2</label>
    
    <div><input type="text" name="address_2" id="address_2" value=""/></div>
    
    
    
    <label for="city">City</label>
    
    <div><input type="text" name="city" id="city" disabled="disabled" value="Los Angeles" /></div>
    
    
    
    <label for="state">State</label>
    
    <div><input type="text" name="state" id="state" disabled="disabled" value="CA" /></div>
    
    
    
    <label for="zipcode">Zip Code</label>
    
    <div><input type="text" name="zipcode" id="zipcode" disabled="disabled" value="90064" /></div>
    
    
    
    <label for="phone">Phone</label>
    
    <div><input type="text" name="phone" id="phone" value="" /></div>
    
    
    
    <input type="checkbox" onclick="FillBilling(this.form)" name="billingtoo">
    
    <em>Check this box if Billing Address and Mailing Address are the same.</em>
    
    
    
    <h1>BILLING ADDRESS</h1>
    
    
    
    <label for="billng_first_name">First Name</label>
    
    <div><input type="text" name="billng_first_name" id="billng_first_name" value="" /></div>
    
    
    
    <label for="billng_last_name">Last Name</label>
    
    <div><input type="text" name="billng_last_name" id="billng_last_name" value="" /></div>
    
    
    
    <label for="billing_address_1">Address 1</label>
    
    <div><input type="text" name="billing_address_1" id="billing_address_1" value=""/></div>
    
    
    
    <label for="billing_address_2">Address 2</label>
    
    <div><input type="text" name="billing_address_2" id="billing_address_2" value=""/></div>
    
    
    
    <label for="billing_city">City</label>
    
    <div><input type="text" name="billing_city" id="billing_city"  value="" /></div>
    
    
    
    <label for="billing_state">State</label>
    
    <div><input type="text" name="billing_state" id="billing_state" value="" /></div>
    
    
    
    <label for="billing_zipcode">Zip Code</label>
    
    <div><input type="text" name="billing_zipcode" id="billing_zipcode" value="" /></div>
    
    
    
    <div><input type="submit" value="Send" /></div>
    
    
    
    </form>
    
  • SNaRe
    SNaRe over 12 years
    Thank you very much. These are small things but when you don't see it makes person mad. Thanks again.
  • david
    david over 12 years
    Yes SNaRe i know what you mean, also rember to tick the answer as accepted
  • SNaRe
    SNaRe over 12 years
    Sorry. I'm a new stackoverflow user. I don't know why I wasn't using here before.
  • david
    david over 12 years
    yeah its a great community website, and everyone is willing to help when they can