]|V|[agnus
10-06-2004, 10:49 PM
Got a checkout page with inputs for billing information, addresses, etc. If there billing address and shipping address are the same, I want to copy whatever values are in one set to the other.
// the function
function matchAddresses() {
var d = document;
// billing fields
var a = d.getElementById("address");
var c = d.getElementById("city");
var s = d.getElementById("state");
var z = d.getElementById("zip");
// shipping fields
var as = d.getElementById("addressShipping");
var cs = d.getElementById("cityShipping");
var ss = d.getElementById("stateShipping");
var zs = d.getElementById("zipShipping");
// set shipping fields equal to billing fields
as.value = a.value;
cs.value = c.value;
ss.value = s.value;
zs.value = z.value;
return false;
}
<!-- the markup -->
<input type="checkbox" name="matchAddresses" id="matchAddresses" value="" class="checkbox" onclick="return matchAddresses()">
<label for="matchAddresses" class="inline" onclick="return matchAddresses()">Shipping address is the same »</label>
FF says "not a function" and IE says "Object doesn't support this property or method"
It's probably some stupid typo I manage to consistently overlook, but everything seems to be in order...
// the function
function matchAddresses() {
var d = document;
// billing fields
var a = d.getElementById("address");
var c = d.getElementById("city");
var s = d.getElementById("state");
var z = d.getElementById("zip");
// shipping fields
var as = d.getElementById("addressShipping");
var cs = d.getElementById("cityShipping");
var ss = d.getElementById("stateShipping");
var zs = d.getElementById("zipShipping");
// set shipping fields equal to billing fields
as.value = a.value;
cs.value = c.value;
ss.value = s.value;
zs.value = z.value;
return false;
}
<!-- the markup -->
<input type="checkbox" name="matchAddresses" id="matchAddresses" value="" class="checkbox" onclick="return matchAddresses()">
<label for="matchAddresses" class="inline" onclick="return matchAddresses()">Shipping address is the same »</label>
FF says "not a function" and IE says "Object doesn't support this property or method"
It's probably some stupid typo I manage to consistently overlook, but everything seems to be in order...