//When Both Address are same

function WhenSameAddress()
{

var check = Xrm.Page.getAttribute("new_bothaddressaresame").getValue() ;
if(check==true)
{
//Get Values from Correspondence Address
var street1 = Xrm.Page.getAttribute("new_castreet1").getValue() ;
var street2 = Xrm.Page.getAttribute("new_castreet2").getValue() ;
var street3 = Xrm.Page.getAttribute("new_castreet3").getValue() ;
var country = Xrm.Page.getAttribute("new_cacountry").getValue() ;
var state = Xrm.Page.getAttribute("new_castate").getValue() ;
var city= Xrm.Page.getAttribute("new_cacity").getValue() ;
var pincode = Xrm.Page.getAttribute("new_capincode").getValue() ;
//alert(street1 + street2 + street3);
//Set values to permanent Address

Xrm.Page.getAttribute("new_pastreet1").setValue(street1);
//Xrm.Page.getControl("new_pastreet1").setFocus(true);
Xrm.Page.getAttribute("new_pastreet2").setValue(street2);
Xrm.Page.getAttribute("new_pastreet3").setValue(street3);
Xrm.Page.getAttribute("new_pacountry").setValue(country);
Xrm.Page.getAttribute("new_pastate").setValue(state);
Xrm.Page.getAttribute("new_pacity").setValue(city);
Xrm.Page.getAttribute("new_papincode").setValue(pincode);



}
else
{
Xrm.Page.getAttribute("new_pastreet1").setValue(' ');
//Xrm.Page.getControl("new_pastreet1").setFocus();
Xrm.Page.getAttribute("new_pastreet2").setValue(' ');
Xrm.Page.getAttribute("new_pastreet3").setValue(' ');
Xrm.Page.getAttribute("new_pacountry").setValue();
Xrm.Page.getAttribute("new_pastate").setValue();
Xrm.Page.getAttribute("new_pacity").setValue();
Xrm.Page.getAttribute("new_papincode").setValue();


}
}


SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012