function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC pvSFDC pv 

Hi I am setting picklist value in table format. How do i pass the selected picklist value to salesforce in lightning. Please help

                                        <td class="slds-truncate">
                                            <select>
                                              <option value="">Please select</option>
                                              <option value="xxx">xxx</option>
                                              <option value="yyy">yyy</option>
                                              <option value="zzz">zzz</option>
                                            </select>
                                        </td>
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you.

As you are using HTML tag to display picklist you can use below line of code to get the selected value from the picklist.

Component:
<select aura:id="categoryPicklist" onchange="{!c.change}">
                            <option value="">Please select</option>
                            <option value="xxx">xxx</option>
                            <option value="yyy">yyy</option>
                            <option value="zzz">zzz</option>
                        </select>

Controller:
({
	change : function(component, event, helper) {
		var pick = component.find("categoryPicklist").getElement().value;
        alert(pick);
	}
})


If you use <lightning:select> then you can use below code to get the selected value from the picklist.

Component:
 
<lightning:select aura:id="categoryPicklist" label="Picklist" onchange="{!c.change}">
                            <option value="">Please select</option>
                            <option value="xxx">xxx</option>
                            <option value="yyy">yyy</option>
                            <option value="zzz">zzz</option>
                        </lightning:select>

Controller:
({
	change : function(component, event, helper) {
		var pick = component.find("categoryPicklist").get("v.value");
        alert(pick);
	}
})


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas​
SFDC pvSFDC pv
Hi Khan,

It is working fine for single record if i am selecting the picklist value for more than one record getting below error

Uncaught Action failed: c:FFSearchComponent$controller$ReqTypechange [component.find(...).get is not a function]

    ReqTypechange : function(component, event, helper) {
        var pickReqTypeval = component.find("RequestTypePicklist").get("v.value");
        console.log('reqtypevalue-'+pickReqTypeval);
    },
    
    UpgTierchange : function(component, event, helper) {
        var pickUpgTierval = component.find("UpgradeTierPicklist").get("v.value");
        console.log('pickUpgTierval-'+pickUpgTierval);
    },