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

Updated on 20-October-2016 at 10:16 AM

Business Catalyst End of life announcement - find out more details.

This script will populate the billing information in the checkout form if the customer selects the "Same as shipping" checkbox. Add this code to the checkbox:

 

<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>