You need to sign in to do that
Don't have an account?
Sabrent
Passing Selected Picklist Value to Apex Controller in lightning
In visualforce page I could do this <apex:actionSupport event="onchange" action="{!pickvalOnChange}" />
I have built a picklist of users . how can i pass the selected picklist value to apex controller in lightning. ?
I have built a picklist of users . how can i pass the selected picklist value to apex controller in lightning. ?
<aura:component controller="BuildPicklistOfUsers" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" > <aura:handler name="init" value="{!this}" action="{!c.doInit}"></aura:handler> <aura:attribute name="users" type="user[]"></aura:attribute> <lightning:select label="Choose User" name="uzr" aura:id="uzr"> <aura:iteration items="{!v.users}" var="user"> <option value="{!user.Id}">{!user.Name}</option> </aura:iteration> </lightning:select> </aura:component> // client side controller ({ doInit: function(component, event, helper) { var action = component.get("c.getUserList"); console.log("@@@action",action); action.setCallback(this, function(result){ var users = result.getReturnValue(); console.log("@@@@users",users); component.set("v.users", users); window.setTimeout( $A.getCallback( function() { component.find("uzr").set("v.value", users[4].Id); })); }); $A.enqueueAction(action); } }) // Server side controller global class BuildPicklistOfUsers { @AuraEnabled global static User[] getUserList() { return [SELECT id, Name FROM User]; } }
All Answers
To get the values from a normal select list, you can do something like this: Where "selectList" is the select list: Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are facing a similar issue.
Thanks,
Nagendra
Truly appreciate your help.