+ Start a Discussion
Dhilip DussaDhilip Dussa 

Need help on Lightning Buttons

Hi Everyone,

In need some help on command buttons

I created the text field and also created the button

if I enter any text and click on save button i need to disply the text
This is fine am able to the text

but i need to save it if i enter another text i need  both text values like n text values 

Thanks,
Dhilip
sachinarorasfsachinarorasf
Hi Dhilip Dussa,

I have gone through your problem.

Here is the code as per the requirements And you can use it. 
 
<<---------------Component------------->>

<aura:component >
    <aura:attribute name="textValue" type="String"/>
    <aura:attribute name="addTextValue" type="String"/>
    <lightning:input type="text" label="Input Text" value="{!v.textValue}"/>
    <lightning:button variant="brand" label="Save" title="Save" onclick="{! c.clickSave }" />
</aura:component>

<<--------------JS controller ------------>>>

({
    clickSave : function(c, e, h) {
        var textValue = c.get('v.textValue');
        if(textValue != undefined && textValue.trim() != ""){
            var addtextValue = c.get('v.addTextValue');
            if(addtextValue == undefined){
                addtextValue = textValue;
            }else{
                addtextValue += textValue;
            }
            c.set('v.addTextValue', addtextValue)
        }
    }
})

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora