PDA

View Full Version : blablah is not a function... but it *is*


]|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 &raquo;</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...

sad69
10-06-2004, 10:53 PM
It could be because your function is the same name as the NAME and ID attribute of your checkbox.. try changing the name and id and it might just work.

If not, post back and we'll try and debug it further.

Sadiq.

]|V|[agnus
10-06-2004, 10:56 PM
Ooh, good call! I bet that's it...

*checks*

Yup! Thanks. :thumbsup: