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
Jaya Koti MuleJaya Koti Mule 

Custom Chat Application

Hi All,
I have a Lightning component which has a InpuText, outputText and a button. when I enter te in InputText and clicked the button, It is displayed in the OutputText. But when I enter again some text in InputText and clicked the button the outputText is erased and the InputText is dispalyed there. But I need to display the first InputText as well as seond InputText and so on....

PFB the code:
Component Code:
--------------------------
<aura:component>              
     <legend class="slds-form-element__label"><b>You entered:</b></legend>
        <ui:outputText aura:id="outText" value="" class="slds-col--padded" />
                           
         <ui:inputText aura:id="userText" class="slds-input" labelClass="slds-form-element__label"
                                          placeholder="Enter User Text"/> 
                                    
         <ui:button aura:id="button" label="Ask" class="slds-button slds-button--brand" press="{!c.getInput}"/>                  
</aura:component>

Conroller Code:
----------------------

({
    getInput : function(component, evt) {
        var UserInputText = component.find("userText");      
        var myOutputText = component.find("outText");
        
        if($A.util.isEmpty(UserInputText.get("v.value")) || $A.util.isUndefined(UserInputText.get("v.value"))){
            alert('Please Enter Text in the Input Box');
            return;
        }   
        var greet = UserInputText.get("v.value");
        
        myOutputText.set("v.value", greet);
        UserInputText.set("v.value", null);
    }
})
 

Thanks in Advance