<apex:page standardController="Contact" extensions="ContactExtn" id="pgContact">
<script type="text/javascript">
function copyAddress() {
// Variables for Billing Address
var copy_BillingPostalCode = document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBPostalCode').value;
var copy_BillingAddress1 =document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBAdd1').value;
var copy_BillingAddress2 = document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBAdd2').value;
var copy_BillingAddress3 = document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBAdd3').value;
var copy_BillingCity = document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBCity').value;
var copy_BillingState = document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBState').value;
var copy_BillingCountry = document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBCountry').value;
// Copying the Billing Address to the Shipping Address
if(copy_BillingPostalCode != null)
{
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSPostalCode').value = copy_BillingPostalCode;
}
if(copy_BillingAddress1 != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSAdd1').value = copy_BillingAddress1;
}
if(copy_BillingAddress2 != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSAdd2').value = copy_BillingAddress2;
}
if(copy_BillingAddress3 != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSAdd3').value = copy_BillingAddress3;
}
if(copy_BillingCity != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSCity').value = copy_BillingCity;
}
if(copy_BillingState != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSState').value = copy_BillingState;
}
if(copy_BillingCountry != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifSCountry').value = copy_BillingCountry;
}
}
</script>
<apex:form id="fmContact">
<apex:sectionHeader title="Contact Information" subtitle="{!Contact.Name}"/>
<apex:pageBlock mode="Edit" id="pbContact">
<apex:pageBlockSection showHeader="true" collapsible="false" columns="2" title="Billing Address Information" id="pbsBillingAdd">
<apex:inputField value="{!Contact.Billing_Postal_Code__c}" id="ifBPostalCode"/>
<apex:inputField value="{!Contact.Billing_City__c}" id="ifBCity"/>
<apex:inputField value="{!Contact.Billing_Address_Line_1__c}" id="ifBAdd1"/>
<apex:inputField value="{!Contact.Billing_State__c}" id="ifBState"/>
<apex:inputField value="{!Contact.Billing_Address_Line_2__c}" id="ifBAdd2"/>
<apex:inputField value="{!Contact.Billing_Country__c}" id="ifBCountry"/>
<apex:inputField value="{!Contact.Billing_Address_Line_3__c}" id="ifBAdd3"/>
</apex:pageBlockSection>
<apex:pageBlockSection showHeader="true" collapsible="false" columns="2" title="Shipping Address Information" id="pbsShippingAdd">
<apex:inputField value="{!Contact.Shipping_Postal_Code__c}" id="ifSPostalCode"/>
<a HREF="#" onClick="return copyAddress();">Copy Billing Address to Shipping Address</a>
<apex:inputField value="{!Contact.Shipping_Address_Line_1__c}" id="ifSAdd1"/>
<apex:inputField value="{!Contact.Shipping_City__c}" id="ifSCity"/>
<apex:inputField value="{!Contact.Shipping_Address_Line_2__c}" id="ifSAdd2"/>
<apex:inputField value="{!Contact.Shipping_State__c}" id="ifSState"/>
<apex:inputField value="{!Contact.Shipping_Address_Line_3__c}" id="ifSAdd3"/>
<apex:inputField value="{!Contact.Shipping_Country__c}" id="ifSCountry"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>