Skip to content Skip to sidebar Skip to footer

How To Copy The Shipping Address To Billing Address

I like to know if I can copy the shipping address to billing address. When a user clicks same as shipping address checkbox. The shipping address value will be copied to billing inp

Solution 1:

Give this a try.

var state = $('#state option:selected').val();
$('#bstate option[value=' + state + ']').attr('selected','selected');

Solution 2:

does this work ?

  $('#bstate').val($('#state').val());

you may need to add id attribute to that billing and shipping state select as 'astate' and 'bstate', as i can't seems to find one :)


Solution 3:

// make billing same as address
    $('input[name=same]').click(function() {
    //alert('Using the same address');  
    if ($("input[name=same]:checked").is(':checked')) { 
      $('#account_bill_fname').val($('#account_fname').val());
      $('#account_bill_lname').val($('#account_lname').val());
      $('#account_bill_address1').val($('#account_address1').val());
      $('#account_bill_address2').val($('#account_address2').val());
      $('#account_bill_city').val($('#account_city').val());             
      var state = $('select[name=account_state] option:selected').val(); 
      $('select[name=account_bill_state] option[value=' + state + ']').attr('selected','selected');
      var country = $('select[name=account_country] option:selected').val();                            
      $('select[name=account_bill_country] option[value=' + country + ']').attr('selected','selected');      
      $('#account_bill_postal').val($('#account_postal').val());
      };              
    });

on the html page the state and country are dropdowns and the checkbox is:

<input type="checkbox" name="same" value="Y" />

Post a Comment for "How To Copy The Shipping Address To Billing Address"