Javascript help - same as customer info script issue

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
izzysanime

Javascript help - same as customer info script issue

Post by izzysanime »

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 :

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>
This is the code for the first step form fields :

Code: Select all

<input name="customerInfoLastName" id="customerInfoLastName" type="text" class="form"
				onchange="set_billing(billingaddrsame);set_deliver(deliveraddrsame)(billingaddrsame)" size="20"
	  			  value=""
				>
Let me know if you need any more info.

Thanks,
Josh
izzysanime

Re: Javascript help - same as customer info script issue

Post by izzysanime »

or if anyone know of a script that can do the same thing with out this issue, send me the link

Thanks,
Josh
izzysanime

Re: Javascript help - same as customer info script issue

Post by izzysanime »

I just tried removing the

Code: Select all

 onchange="set_billing(billingaddrsame);set_deliver(deliveraddrsame)"
that is at the first step.  It appears to not have that glitch now and it still copies the info when the check box is checked.  BUT it wont automatically change the copied information when the visitor changes a field in step 1.

Thanks,
Josh
Post Reply

Return to “The Lounge”