PDA

View Full Version : "same address as" script clearing scripts



izzysanime
04-17-2008, 04:49 PM
Not sure If i got it here, I think so, but can not find it, it is a script that copies the form in customer info address and places it into the billing fields and shipping fields.

I have a customer info field and if the pickup address or delivery address is the same as the customer info, the user can click on a check box and it will pop in the info into one or both of the fields.

This is the URL, it is live FYI - http://www.fishershippingcompany.com/order.html

As you can see their is the customer info area and the pickup area and delivery area, the check box is there and that part all works. The glitch is that if you fill in the areas that the form info duplicated into first and then fill in the main customer info last, all of the fields for the pickup and delivery info disappear. Try it, fill in the pickup info, then the delivery info area, then finally the top customer info last, and see what happens.

Any suggestions would be great?

Thanks,
Josh

izzysanime
04-17-2008, 04:50 PM
1) Script Title:
Not sure If i got it here, I think so, but can not find it, it is a script that copies the form in customer info address and places it into the billing fields and shipping fields.

2) Script URL (on DD): http://www.dynamicdrive.com/notsure.hrtml

3) Describe problem:
I have a customer info field and if the pickup address or delivery address is the same as the customer info, the user can click on a check box and it will pop in the info into one or both of the fields.

This is the URL, it is live FYI - http://www.fishershippingcompany.com/order.html

As you can see their is the customer info area and the pickup area and delivery area, the check box is there and that part all works. The glitch is that if you fill in the areas that the form info duplicated into first and then fill in the main customer info last, all of the fields for the pickup and delivery info disappear. Try it, fill in the pickup info, then the delivery info area, then finally the top customer info last, and see what happens.

This is the JS in the head,


<script type="text/javascript" language="javascript">
function set_billing(box)
{
var f = box.form, b_which = box.checked, from_el, to_el, i = 0;
var fld_name = new Array('customerInfoBusiness' , 'customerInfoLastName' , 'customerInfoFirstName' ,'customerInfoAddress' ,'customerInfoCity' ,'customerInfoState' ,'customerInfoZip' ,'customerInfoPhones' , '');
while (from_el = f[fld_name[i]])
{
to_el = f['p' + fld_name[i++]];
to_el.value = b_which ? from_el.value : '';
if (to_el.readOnly != null)
to_el.readOnly = b_which ? true : false;
else to_el.onfocus = b_which ? function() {this.blur();
}
: null;
}
}
</script>

<script type="text/javascript" language="javascript">
function set_deliver(box)
{
var f = box.form, b_which = box.checked, from_el, to_el, i = 0;
var fld_name = new Array('customerInfoBusiness' , 'customerInfoLastName' , 'customerInfoFirstName' ,'customerInfoAddress' ,'customerInfoCity' ,'customerInfoState' ,'customerInfoZip' ,'customerInfoPhones');
while (from_el = f[fld_name[i]])
{
to_el = f['d' + fld_name[i++]];
to_el.value = b_which ? from_el.value : '';
if (to_el.readOnly != null)
to_el.readOnly = b_which ? true : false;
else to_el.onfocus = b_which ? function() {this.blur();
}
: null;
}
}
</script>


This is around the fields that are the default customer info


<input name="customerInfoLastName" id="customerInfoLastName" type="text" class="form"
onchange="set_billing(billingaddrsame);set_deliver(deliveraddrsame)(billingaddrsame)" size="20"
value=""
>


Any suggestions would be great?



Thanks,
Josh