OR you can directly get the value using component.get("v.picklistValue");
But what if you need the display text instead of value ?
Check below example to get the selected value's text from a picklist using the index in it.
Component
1 2 3 4 5 | <lightning:select aura:id="selectPicklist" value="{!v.Plv}" onchange="{!c.handleChange}"> <aura:iteration items="{!v.Options}" var="item" indexVar="index"> <option value="{!item.key}" selected="{!item.key==v.Plv}">{!item.value}</option> </aura:iteration> </lightning:select> |
Controller
1 2 3 4 5 | var myValues= component.get("v.Options"), value = component.find("selectPicklist").get("v.value"), index = myValues.findIndex(item => item.key == value), selectedName = index >= 0? myValues[index].value: null; console.log('#####Name : '+selectedName ); |
If you have any question please leave a comment below.
If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !
Thanks
Keep Coding
0 Comments