function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sid LightningSid Lightning 

Auto Fill the same value in another field, while typing

Hi,
 

I have two fields, Shipping Address and Billing Address,

I want to copy the value of shipping address into billing address, while typing the value in shipping address, 

How can I achieve this.

There is a checkbox, which when checked, clears the value of billing address.
So when billing address is different, User can go and fill nee address

Ramesh DRamesh D
@sid where do you want this to implement? lightning form/lwc/vf page?
Sid LightningSid Lightning
Lightning component
Ramesh DRamesh D
Try below code and change as per you need
 
<aura:component implements="lightning:isUrlAddressable,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
   
    <aura:attribute name="RegForm" type="Account" default="{'sobjectType' : 'Account'}"/>    
    <div class = "slds-size--3-of-8">
        <div class="slds-section slds-is-open">
            <h3 class="slds-section__title slds-theme_shade">
                <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Billing Address</span>
            </h3>
            <br/>
            <div aria-hidden="false" class="slds-section__content">
                <lightning:input label="Billing Street " name="BillingStreet" onchange="{!c.onAddressChange}" value="{!v.RegForm.BillingStreet}"/>
                <br/>
                <lightning:input label="Billing City" name="BillingCity" onchange="{!c.onAddressChange}" value="{!v.RegForm.BillingCity}"/>
                <br/>
                <lightning:input label="Billing State" name="BillingState" onchange="{!c.onAddressChange}" value="{!v.RegForm.BillingState}"/>
                <br/>
                <lightning:input label="Billing Country" name="BillingCountry" onchange="{!c.onAddressChange}" value="{!v.RegForm.BillingCountry}"/>
                <br/>
               
            </div>
        </div>
        <br/> 
        <div class="slds-section slds-is-open">
            <h3 class="slds-section__title slds-theme_shade">
                <span class="slds-truncate slds-p-horizontal_small" title="Section Title">Shipping Address</span>
            </h3>
            <br/>
            <div aria-hidden="false" class="slds-section__content">
                <lightning:input label="Shipping Street " name="ShippingStreet" value="{!v.RegForm.ShippingStreet}"/>
                <br/>
                <lightning:input label="Shipping City" name="ShippingCity" value="{!v.RegForm.ShippingCity}"/>
                <br/>
                <lightning:input label="Shipping State" name="ShippingState" value="{!v.RegForm.ShippingState}"/>
                <br/>
                <lightning:input label="Shipping Country" name="ShippingCountry" value="{!v.RegForm.ShippingCountry}"/>
            </div>
        </div>
    </div>
</aura:component>


({
    onAddressChange : function(component, event, helper) {        
        
        var streetStr=component.get("v.RegForm.BillingStreet");
        var cityStr=component.get("v.RegForm.BillingCity");
        var stateStr=component.get("v.RegForm.BillingState");
        var countryStr=component.get("v.RegForm.BillingCountry");
            component.set("v.RegForm.ShippingStreet",streetStr);
            component.set("v.RegForm.ShippingCity",cityStr);
            component.set("v.RegForm.ShippingState",stateStr);
            component.set("v.RegForm.ShippingCountry",countryStr);
    }
})


Thanks
Ramesh