You need to sign in to do that
Don't have an account?
Prakhar K
in lightning , how to get user selected value of dynamic picklist in controller ?
I have made a picklist having dynamic values of picklist but I am unable to get the user selected value in controller.When user selects any of the values ,a function called "showTemplateText" fires up and here I want to get the user selected value. Below is the Component code and Controller code .
Component Code Snippet:
<aura:attribute name="templates" type="Message_Template__c[]" /> //object of type Message_Template__c//
<select id="msg-template" name="msg.id" style="width:200px;" onchange="{!c.showTemplateText}" class="form-control is-filled" aria-invalid="false">
<option>--Select Msg Template--</option>
<aura:iteration items="{!v.templates}" var="templ" >
<ui:inputSelectOption text="{!templ.Name}" /> //it shows value in front end but did not send any value at back end.any ideas?//
</aura:iteration>
</select>
----------------------------------------------------------------------------------
function showTemplateText in controller
showTemplateText: function(component, event, helper){
var variable=component.get("v.templates[1].Text_Template__c"); //but using this i get a specific value no matter what i select in picklist.
}
-------------------------------------
Component Code Snippet:
<aura:attribute name="templates" type="Message_Template__c[]" /> //object of type Message_Template__c//
<select id="msg-template" name="msg.id" style="width:200px;" onchange="{!c.showTemplateText}" class="form-control is-filled" aria-invalid="false">
<option>--Select Msg Template--</option>
<aura:iteration items="{!v.templates}" var="templ" >
<ui:inputSelectOption text="{!templ.Name}" /> //it shows value in front end but did not send any value at back end.any ideas?//
</aura:iteration>
</select>
----------------------------------------------------------------------------------
function showTemplateText in controller
showTemplateText: function(component, event, helper){
var variable=component.get("v.templates[1].Text_Template__c"); //but using this i get a specific value no matter what i select in picklist.
}
-------------------------------------
The init function to populate value
So i guess in your case you should try using ui:inputSelect rather than normal Select .