0

I would like to get what the user has selected from a drop down list and pass that into a controller. I thought using the line below would get the user selected option but it just shows the label on my component:

var cmp = cmp.find('aura:id).get('v.label');

<lightning:select name="selectItem" label="Select an item"  aura:id="test" onchange="{!c.test}">
   <option value="">choose one...</option>
   <option value="1">one</option>
   <option value="2">two</option>
</lightning:select>

So I would like 1 of the options i.e 'one' to be stored in a variable. However, the code above just shows the label on the lightning select i.e. 'Select an item'

0

Hi you have to fetch value instead of label i.e.

var cmp = cmp.find('test').get('v.value');

For more reference please have a look to salesforce docs.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.