Jeremy Chambers
Jeremy Chambers

Reputation: 125

Why isn't the address for billing copying to shipping?

So I know that fields are properly named, but javascript is still not copying info over when the check box is checked. I have double checked and everything matches up in the fields.

JavaScript:

function FillShiping(f) {
    if(f.shipingtoo.checked == true) {
        f.shipto.value = f.billto.value;
        f.shipaddress.value = f.Address.value;
        f.shipcity.value = f.City.value;
        f.shipstate.value = f.State.value;
        f.shipzip.value = f.Zip.value;
    }

    if(f.shipingtoo.checked == false) {
        f.shipto.value = '';
        f.shipaddress.value = '';
        f.shipcity.value = '';
        f.shipstate.value = '';
        f.shipzip.value = '';
    }
}

HTML:

<div class="fb-checkbox">
    <input type="checkbox" onclick="Fillshiping(this.form)" name="shipingtoo">
    <span class="fb-fieldlabel" id="item61_0_span">Check this if shipping address is same
                        as billing address </span>
    </label>
</div>
</div>

Upvotes: 0

Views: 149

Answers (1)

Felix Kling
Felix Kling

Reputation: 816522

The console shows the error:

ReferenceError: Fillshiping is not defined

You named the function FillShiping, but you are calling Fillshiping(this.form) (lowercase s).

After correcting your fiddle and naming the function properly, it seems to work.


Use your browser's developer tools to debug your code, it's invaluable.

Upvotes: 4

Related Questions