A couple of things I'd change. You have 20 references to the same form and
your formatting isn't the best.

1. Make a shortened reference to the form, f. This will reduce the amount of
text/typing and a form name change can be done in one place.

2. Don't indent the large block beneath the one line if statement. It makes
it look like it's part of the if block.

3. Also, space some of your code out, opps, that's three things...

4. Ahhh christ, now it's four... I'm not sure about this but be careful with
variable names like checkbox, I'm sure that one's ok but you might get in
trouble with others.

function CopyAddress(checkbox)
{

        var f = document.form1;

        if ( checkbox.checked == false ) { return; }

        f.s_fname.value = f.fname.value;
        f.s_lname.value = f.lname.value;
        f.s_address1.value = f.address1.value;
        f.s_address2.value = f.address2.value;
        f.s_city.value = f.city.value;
        f.s_state.value = f.state.value;
        f.s_zipcode.value = f.zip.value;
        f.s_country.value = f.country.value;
        f.s_phone.value = f.phone.value;
        f.s_email.value = f.email.value;

}

Ade

-----Original Message-----
From: Will Tomlinson [mailto:[EMAIL PROTECTED]
Sent: 28 May 2005 18:16
To: CF-Talk
Subject: Figured out the billing>shipping population - here it is


K guys, thanks for your help.

This is my working JS code for auto-populating the ship to inputs. If you
see anything that can be improved let me know.

Thanks,
Will

<InvalidTag type="text/javascript" language="javascript">
// function to copy billing address to shipping address
function   CopyAddress(checkbox)
{
 if(checkbox.checked == false) { return; }
   document.form1.s_fname.value = document.form1.fname.value;
   document.form1.s_lname.value = document.form1.lname.value;
   document.form1.s_address1.value = document.form1.address1.value;
   document.form1.s_address2.value = document.form1.address2.value;
   document.form1.s_city.value = document.form1.city.value;
   document.form1.s_state.value = document.form1.state.value;
   document.form1.s_zipcode.value = document.form1.zip.value;
   document.form1.s_country.value = document.form1.country.value;
   document.form1.s_phone.value = document.form1.phone.value;
   document.form1.s_email.value = document.form1.email.value;

 }
</script>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207957
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to