Javascript help - same as customer info script issue
Posted: Wed Apr 23, 2008 6:18 pm
Hi,
I have a form feature that will copy the already inputed form given by the visitor (eg: name, address, zip) and when a check box is checked it will put that form info again into the pickup address, and then another check box that will put the same info into the delivery address area.
The issue is that if the visitor does not enter the info in the first step area that the script grabs from, it will remove the form info when the visitor does go to the first step. And if the visitor decides to change something in either field it will remove everything. Any ideas? Here is the code :
This is the code for the first step form fields :
Let me know if you need any more info.
Thanks,
Josh
I have a form feature that will copy the already inputed form given by the visitor (eg: name, address, zip) and when a check box is checked it will put that form info again into the pickup address, and then another check box that will put the same info into the delivery address area.
The issue is that if the visitor does not enter the info in the first step area that the script grabs from, it will remove the form info when the visitor does go to the first step. And if the visitor decides to change something in either field it will remove everything. Any ideas? Here is the code :
Code: Select all
<__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>
Code: Select all
<input name="customerInfoLastName" id="customerInfoLastName" type="text" class="form"
onchange="set_billing(billingaddrsame);set_deliver(deliveraddrsame)(billingaddrsame)" size="20"
value=""
>
Thanks,
Josh