Setting the billing address to be the same as the shipping address

    This script will populate the billing address in the checkout form, with shipping address details if the customer selects the "Same as shipping" checkbox.

     

     

    Add this checbox to the form somewherebetween shipping and billing address fields:

     

     

    <input type="checkbox" onclick="SetBilling(this.checked);"/> Same as Shipping
    

     

    And then, at the bottom of the page, add the following JavaScript function:

     

    <script type="text/javascript">
    function SetBilling(checked) {
              if (checked) {
                        document.getElementById('BillingAddress').value = document.getElementById('ShippingAddress').value; 
                        document.getElementById('BillingCity').value = document.getElementById('ShippingCity').value; 
                        document.getElementById('BillingState').value = document.getElementById('ShippingState').value; 
                        document.getElementById('BillingZip').value = document.getElementById('ShippingZip').value; 
                        document.getElementById('BillingCountry').value = document.getElementById('ShippingCountry').value; 
              } else {
                        document.getElementById('BillingAddress').value = ''; 
                        document.getElementById('BillingCity').value = ''; 
                        document.getElementById('BillingState').value = ''; 
                        document.getElementById('BillingZip').value = ''; 
                        document.getElementById('BillingCountry').value = ''; 
              }
    }
    </script>