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
Aaqib Niaz 5Aaqib Niaz 5 

OnChange event throws an error when trying to select the picklist Field.

I have a picklist which gives the below error when trying to select a value.
User-added image
<lightning:select aura:id="Productreg" name="select" label="Gender" onchange="{!c.onSelectChange}">
                        <option value="">choose one...</option>
                        <option value="male">Male</option>
                        <option value="female">Female</option>

 onSelectChange: function (cmp, evt, helper) {
        //alert(cmp.find('select').get('v.value') );
        var genderVal = cmp.find('select').get('v.value');
    afterload: function (cmp, evt, helper) {
        alert('new function test' );
    handleCreateProductReg: function (cmp, evt, helper) {
        var CreatePassableItem = component.get('c.CreatePassableItem');
        var prodObj = cmp.get("v.ProductRegObj");
        var genderVal = cmp.get("v.genderVal")?cmp.get("v.genderVal"):''; 
        prodObj.Gender__c = genderVal;
Danish HodaDanish Hoda

hi Aaqib,
you have used 'aura:id="Productreg"' but fetching <select> 'var genderVal = cmp.find('select').get('v.value');' in the code.

instead use  var genderVal = cmp.find('Productreg').get('v.value');

Aaqib Niaz 5Aaqib Niaz 5
Hello Danish,
After changing 'select' to 'Prodreg' it gives the following error.
[cmp.find(...).get is not a function]
Piyush jadavPiyush jadav


You can use 


to get selected value