Have a question about CiviCRM? Get it answered quickly at the new CiviCRM Stack Exchange Q+A siteThis forum was archived on 25 November 2017. Learn more.How to get involved.What to do if you think you've found a bug.
<SCRIPT LANGUAGE="JavaScript">{literal} function copyAddress(sameAsBilling) { var firstName = document.getElementById('billing_first_name').value; var lastName = document.getElementById('billing_last_name').value; var streetAddress = document.getElementById('street_address-5').value; var city = document.getElementById('city-5').value; var stateProvince = document.getElementById('state_province_id-5').value; var postalCode = document.getElementById('postal_code-5').value; var country = document.getElementById('country_id-5').value; var copy_firstName = document.getElementById('first_name'); var copy_lastName = document.getElementById('last_name'); var copy_streetAddress = document.getElementById('street_address-Primary'); var copy_city = document.getElementById('city-Primary'); var copy_stateProvince = document.getElementById('state_province-Primary'); var copy_postalCode = document.getElementById('postal_code-Primary'); var copy_country = document.getElementById('country-Primary'); if (sameAsBilling.checked) { if (copy_firstName) copy_firstName.value = firstName; if (copy_lastName) copy_lastName.value = lastName; if (copy_streetAddress) copy_streetAddress.value = streetAddress; if (copy_city) copy_city.value = city; if (copy_stateProvince) copy_stateProvince.value = stateProvince; if (copy_postalCode) copy_postalCode.value = postalCode; if (copy_country) copy_country.value = country; } else { if (copy_firstName) copy_firstName.value = ""; if (copy_lastName) copy_lastName.value = ""; if (copy_streetAddress) copy_streetAddress.value = ""; if (copy_city) copy_city.value = ""; if (copy_stateProvince) copy_stateProvince.value = ""; if (copy_postalCode) copy_postalCode.value = ""; if (copy_country) copy_country.value = ""; }}{/literal}</SCRIPT> <input type="checkbox" id="same_as_billing" value="" onClick="copyAddress(this)"> Mailing address is the same as the billing address.
Index: templates/CRM/Contribute/Form/Contribution/Main.tpl===================================================================--- templates/CRM/Contribute/Form/Contribution/Main.tpl (revision 26002)+++ templates/CRM/Contribute/Form/Contribution/Main.tpl (working copy)@@ -209,8 +209,13 @@ </fieldset> {/if} - {if $is_monetary} - {include file='CRM/Core/BillingBlock.tpl'} + {if $is_monetary}+ {include file='CRM/Core/BillingBlock.tpl'} + <div class="section sameAddress-section"> + <div class="label">{ts}Same address as billing{/ts}</div>+ <div class="content"><input type="checkbox" id="sameAddress" value="1"></div>+ <div class="clear"></div> + </div> {/if} <div class="crm-group custom_post_profile-group">@@ -275,6 +280,33 @@ {/if} <script type="text/javascript">+{literal}+cj( function( ) {+ cj('#sameAddress').click( function( ) {+ sameAddress( this.checked );+ });+});++function sameAddress( setValue ) {+ var locationTypeInProfile = 1;+ var orgID = field = fieldName = null;+ cj('*:is(.billing_name_address-section)[id^=billing_]').each( function( i ){+ orgID = cj(this).attr('id')+ field = orgID.split('-');+ fieldName = field[0].replace('billing_', '');+ if ( field[1] ) {+ fieldName = fieldName.replace('_id', '');+ fieldName = fieldName + '-' + locationTypeInProfile;+ }+ if ( setValue ) {+ cj('#' + fieldName ).val(cj(this).val()); + } else {+ cj('#' + fieldName ).val(''); + }+ });+}+{/literal}+ {if $pcp}pcpAnonymous();{/if} {literal} var is_monetary = {/literal}{$is_monetary}{literal}
Kurund - has your version been committed to core? 3.1?
if ( setValue ) { cj('#' + fieldName ).val(cj(this).val()); $('div.custom_post_profile-group').slideUp();} else { cj('#' + fieldName ).val(''); $('div.custom_post_profile-group').slideDown();}