In One Page Checkout, the Billing class offers a setAddress(val) function that looks useful for setting the address that gets chosen when a user that has saved addresses selects one from the first-step of the checkout process.

When you call, say, setAddress(2) it will populate the hidden form with the proper values for that address. I am doing some custom validation on this form, so I appreciate being able to update the hidden form. I am doing a simple call:

    option = jQuery('#billing-address-select option:selected').val();

However, after a user changes the selected address, after a quick Ajax call, the selected option gets automatically reverted back to the 'New Address' option (which has a null value).

The only thing I can see where this would happen, there is onchange="billing.newAddress(!this.value)" set on the select element. Looking at this method, though, all it is doing is showing or hiding the hidden form as needed.

Why is this form element getting reverted back to the 'New Address' option?

1 Answer 1


Open the file- "skin/frontend/base/default/js/opcheckout.js"

Look into the function billing.fillForm()

Change the code to the one below(the change is in the if condition)-

var elementValues = {};
if (transport && transport.responseText){
        elementValues = eval('(' + transport.responseText + ')');
    catch (e) {
        elementValues = {};
arrElements = Form.getElements(this.form);
for (var elemIndex in arrElements) {
    if (arrElements[elemIndex].id && 'billing-address-select' != arrElements[elemIndex].id) {
        var fieldName = arrElements[elemIndex].id.replace(/^billing:/, '');
        arrElements[elemIndex].value = elementValues[fieldName] ? elementValues[fieldName] : '';
        if (fieldName == 'country_id' && billingForm){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.