You need to sign in to do that
Don't have an account?
Anu Singh 40
how to set id in aura attribute from lightning select for a selected option
Hi ,
I am new to lightning. I have a lightning select for showing options here option are list of contact.
<div>
Contact: <lightning:select name="con" class="slds-combobox_container slds-size_small"
aura:id="con" value="{!v.selectedContact}" onchange="{!c.changeAction}" >
<option value="">choose one...</option>
<aura:iteration items="{!v.conOption}" var="opt">
<option text="{!opt.LastName}" value="{!opt.id}" selected="{!opt.selected}" />
</aura:iteration>
</lightning:select>
</div>
And I have a attribute
<aura:attribute name="selectedContact" type="String" />
I want selectedContact show con.Id But When I am geeting the value in a function using var selectedCon=component.get('v.selectedContact');
it shows Name of contact I want Id of Contact
How Can I do that. Please help
Thankyou in Advance
I am new to lightning. I have a lightning select for showing options here option are list of contact.
<div>
Contact: <lightning:select name="con" class="slds-combobox_container slds-size_small"
aura:id="con" value="{!v.selectedContact}" onchange="{!c.changeAction}" >
<option value="">choose one...</option>
<aura:iteration items="{!v.conOption}" var="opt">
<option text="{!opt.LastName}" value="{!opt.id}" selected="{!opt.selected}" />
</aura:iteration>
</lightning:select>
</div>
And I have a attribute
<aura:attribute name="selectedContact" type="String" />
I want selectedContact show con.Id But When I am geeting the value in a function using var selectedCon=component.get('v.selectedContact');
it shows Name of contact I want Id of Contact
How Can I do that. Please help
Thankyou in Advance
you can get reference from following way for fulfill your requirment.
let me know if it helps you and close your query by marking it as best answer.
if it helps you,it is essential to mark it as best because your best mark give us motivation for working in this way.
Thank you
All Answers
you can get reference from following way for fulfill your requirment.
let me know if it helps you and close your query by marking it as best answer.
if it helps you,it is essential to mark it as best because your best mark give us motivation for working in this way.
Thank you
You can use syntax like below in your js controller like below to get the ID of the selected contact and show it as you want: For more getting more insight on implementation part refer below thread:
https://salesforce.stackexchange.com/questions/106015/lightning-how-do-i-get-the-selected-value-from-a-select-dropdown-list-send-i
Hope above information helps. Please mark as Best Answer so that it can helps others in future.
Thanks.
You can get a reference from this Link-->
https://salesforce.stackexchange.com/questions/201182/lightningselect-bind-the-selected-attribute
if you have any query please comment.
---------------
If you find your Solution then mark this as the best answer to close this question.
Thank you!
Regards,
Suraj Tripathi