I have a checkbox field called “SameAsBillingAddress” which, once cliked, is supposed to copy the values of some fields to other ones (from billing address fields to shipping adress fields).
When the user clicks on the checkbox an IE error message comes up saying “SameAsBillingAddress.checked is null or is not an object”. When I try same in Firefox the following error message comes up saying :
"form.SameAsBillingAddress has no properties
ShipToBillCustomer(form 42e04642140571508425…)42e04642140571508… (line 39)
onclick(click clientX=0, clientY=0)42e04642140571508… (line 1)
if (form.SameAsMailingAddress.checked) {".
The onClick event of the checkbox executes the following function: “ShipToBillCustomer(this.form);”.
The following coe is found in the JSHeader event of the form:
var CustomerAddressShip = “”;
var CustomerCityShip = “”;
var CustomerStateShip = “”;
var CustomerCountryShip = “”;
var CustomerPostalCodeShip = “”;
function InitSaveVariables(form) {
CustomerAddressShip = form.CustomerAddressShip.value;
CustomerCityShip = form. CustomerCityShip.value;
CustomerStateShip = form.CustomerStateShip.value;
CustomerCountryShip = form.CustomerCountryShip.value;
CustomerPostalCodeShip = form.CustomerPostalCodeShip.value;
}
function ShipToBillCustomer(form) {
if (form.SameAsBillingAddress.checked) {
InitSaveVariables();
form.CustomerAddressShip.value = form. CustomerAddress.value;
form.CustomerCityShip.value = form. CustomerCity.value;
form.CustomerStateShip.value = form. CustomerState.value;
form.CustomerCountryShip.value = form. CustomerCountry.value;
form.CustomerPostalCodeShip.value = form. CustomerPostalCode.value;
}
else {
form.CustomerAddressShip.value = CustomerAddressShip;
form.CustomerCityShip.value = CustomerCityShip;
form.CustomerStateShip.value = CustomerStateShip;
form.CustomerCountryShip.value = CustomerCountryShip;
}
}
I based this code based on sample code found on the JavaScript Source Code website (http://javascript.internet.com/forms/copy-fields.html). Can someone show me how to make this work?
Thanks everyone.
Dan