I saw an example here, but not cler where the elementid is being passed from?
Can someone please guide?
(Lightning) How do I get the selected value from a Select dropdown list & send it to a method?
Here's the code snippet
I saw an example here, but not clear where the elementid is being passed from?
Can someone please guide?
(Lightning) How do I get the selected value from a Select dropdown list & send it to a method?
Here's my code snippet. I am trying to get the selected picklist value to be passed to my apex controller
// component
<aura:component
controller="BuildPicklistOfUsers"
implements="flexipage:availableForRecordHome,force:hasRecordId"
access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit} / >
<aura:attribute name="users" type="user[]"></aura:attribute>
<aura:attribute name="myselecteduser" type="String" access="global"/>
<lightning:select label="Choose User" name="uzr" aura:id="uzr" onChange="{! c.onChangeUser }">
<aura:iteration items="{!v.users}" var="user">
<option value="{!user.Id}">{!user.Name}</option>
</aura:iteration>
</lightning:select>
// client side controller ({ doInit: function(component, event, helper) {
var action = component.get("c.getUserList");
action.setCallback(this, function(result){
var users = result.getReturnValue();
component.set("v.users", users);
window.setTimeout(
$A.getCallback( function() {
component.find("uzr").set("v.value", users[4].Id);
}));
});
$A.enqueueAction(action);
},
onChangeUser: function (component, event, helper) {
var selectedUser = component.get("v.uzr");
var action = component.get("c.getSelectedUserId");
action.setParams({
"selectedUser": userid
});
action.setCallback(this, function(response) {
this.getResponse(response, component);
});
$A.enqueueAction(action);
},
getResponse: function(response, component) {
var stringResult = response.getReturnValue();
component.set("v.myselecteduser", stringResult);
}
})