Hi Guys,
I am taking billing & shipping information on a single form. The billing information comes first, then there is a checkbox asking whether billing and shipping information is the same, and the shipping information fields follow that.
I need the billing information values the user types to copy into the shipping information field values. I have tried to do this with Javascript and it works when not in Chrono forms, however when I go back into Chronoforms and try to implement it their, it doesn't work. In fact, any Javascript I place into the "Form JavaScript" section doesn't even appear on the pages source code when I refresh and view the page source.
To make a long story short, I bypassed the "Form Javascript" section in the chronoforms backend and just added the javascript to the "head" section of my index.php file. Here is the code:
When I click the checkbox on my page I get a javascript error in Firebug that states:
"Error: document.ChronoContact_orderform.copy is undefined"
Any ideas?
I am taking billing & shipping information on a single form. The billing information comes first, then there is a checkbox asking whether billing and shipping information is the same, and the shipping information fields follow that.
I need the billing information values the user types to copy into the shipping information field values. I have tried to do this with Javascript and it works when not in Chrono forms, however when I go back into Chronoforms and try to implement it their, it doesn't work. In fact, any Javascript I place into the "Form JavaScript" section doesn't even appear on the pages source code when I refresh and view the page source.
To make a long story short, I bypassed the "Form Javascript" section in the chronoforms backend and just added the javascript to the "head" section of my index.php file. Here is the code:
<script type="text/javascript">
var ChronoContact_orderform="ChronoContact_orderform";
function data_copy()
{
if(document.ChronoContact_orderform.copy[0].checked){
document.ChronoContact_orderform.shipping_address.value=document.ChronoContact_orderform.billing_address.value;
document.ChronoContact_orderform.shipping_address2.value=document.ChronoContact_orderform.billing_address_2.value;
document.ChronoContact_orderform.shipping_city.value=document.ChronoContact_orderform.billing_city.value;
document.ChronoContact_orderform.shippingstate.value=document.ChronoContact_orderform.billing_state.value;
document.ChronoContact_orderform.shippingzip.value=document.ChronoContact_orderform.billing_zip.value;
document.ChronoContact_orderform.shipping_country.value=document.ChronoContact_orderform.billing_country.value;
}else{
document.ChronoContact_orderform.shipping_address.value="";
document.ChronoContact_orderform.shipping_address2.value="";
document.ChronoContact_orderform.shipping_city.value="";
document.ChronoContact_orderform.shippingstate.value="";
document.ChronoContact_orderform.shippingzip.value="";
document.ChronoContact_orderform.shipping_country.value="";
}
}
When I click the checkbox on my page I get a javascript error in Firebug that states:
"Error: document.ChronoContact_orderform.copy is undefined"
Any ideas?
Also,
Here is the code for the checkbox generated by Chronoforms and then edited by me:
Is there an easier way to bypass all of this or am I almost there?
Here is the code for the checkbox generated by Chronoforms and then edited by me:
<div class="form_item">
<div class="form_element cf_checkbox">
<label class="cf_label" style="display: none;">Ship to a Different Address?</label>
<div class="float_left">
<input onClick="data_copy()" value="Ship_to_a_Different Address?" title="" class="radio" id="check00" name="check0[]" type="checkbox" />
<label for="check00" class="check_label">Ship to a Different Address?</label>
<br />
Is there an easier way to bypass all of this or am I almost there?
Hi,
You've got the wrong id. The id of the checkbox is "check00", not copy[0]. Thus, use this instead:
Or, if you prefer using the MooTools library:
/Fredrik
You've got the wrong id. The id of the checkbox is "check00", not copy[0]. Thus, use this instead:
...
if (document.ChronoContact_orderform.check00.checked) {
...
Or, if you prefer using the MooTools library:
...
if ($('check00').checked) {
...
/Fredrik
This topic is locked and no more replies can be posted.