Skip to main content
Question Protected by CommunityBot
Tweeted twitter.com/StackSalesforce/status/809070028796624896
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
wwchiang
  • 111
  • 1
  • 1
  • 3

(Lightning) How do I get the selected value from a Select dropdown list & send it to a method?

I'm trying to implement a single option select dropdown list for my component, and I've gotten as far as displaying the data members and the correct values for them. However, I can't find any example within the SLDS website that gives me an idea of how to get this value out. I'm still new to working with Lightning(and front-end in general).

Here's the code I've written:

<aura:component>
<aura:attribute name="productCategories" type="Object[]"/>

<aura:handler name="change" value="{!v.productCategories}" action="{!c.doInit}"/>

<div class="slds-form-element__control">
    <div class="slds-select_container">
        <select id="categoryPicklist" class="slds-select">
            <option>All</option>
            <aura:iteration items="{!v.productCategories}" var="category" indexVar="index">
                <option>{!category.label}</option>
            </aura:iteration>
        </select>
    </div>
</div>

</aura:component>

How would I get the chosen option data and pass it into my controller?