Support (offered by community volunteers) > Using Profiles
TIP: How to copy address to Profile using JavaScript "Same as billing address"
Kurund Jalmi:
Simplified version of above javascript is here
--- Quote ---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}
--- End quote ---
HTh
Kurund
Eileen:
Kurund - has your version been committed to core? 3.1?
Kurund Jalmi:
--- Quote ---Kurund - has your version been committed to core? 3.1?
--- End quote ---
This is just a hack using custom templates.
Kurund
Eileen:
Shame. Thanks though - there's a lot of demand for this.
bwaindwain:
add the jquery slideUp/slideDown to make the div slide up and down like it does in Ubercart
--- Code: ---if ( setValue ) {
cj('#' + fieldName ).val(cj(this).val());
$('div.custom_post_profile-group').slideUp();
} else {
cj('#' + fieldName ).val('');
$('div.custom_post_profile-group').slideDown();
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version