• Mothi Mullackal
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hey everyone,

I want to grab the value of my label for a dynamic picklist but I am not sure how it is to be done and I have scoured the Internet and have not found anything that works for myself. Right now I am using the value field to grab the ID of an Account from the picklist but I also need to grab the name. I figured I would be able to grab it from the selected option's label but I haven't been able to do it.

Here is the lightning:select in my new lightning component:
<lightning:select aura:id="accountSelect"
    name="account"
    label="Select Account"
    required="true"
     value="{!v.acctId}"
    onchange="{!c.changeAccount}">
        <aura:iteration items="{!v.lstAccount}" var="acct" >
            <option value="{!acct.Id}" >{!acct.Name}</option>
        </aura:iteration>
</lightning:select>

And here is my controller:
changeAccount: function(component,event,helper){
		console.log('Account changed.'); 
        var label = component.find("accountSelect").get("v.label");
        
        console.log('log that it changed, new account name: ' + label);
}

Thanks for any help!