Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

dropdwon send always last value in filter

i’m trying to do a filter using Dropdown but it’s always sending the last value to the link option
enter image description here

always sending the last option
enter image description here

the filter controller work fine. i believe the problem is in the dropdown menu in blade it doesn’t send the option the link

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this is my blade

<form action="{{ action('App\Http\Controllers\HomePageController@processForm') }}" method="POST" class="woocommerce-ordering product-filter">
    @csrf
    <input type="hidden" value="alpha" name="sortoption"id="alpha"> 
    <input type="hidden" value="desc" name="sortoption" id="desc">
    <input type="hidden" value="asc" name="sortoption" id="asc">
                                
    <span class="orderby-label hide-desktop">Sort by</span>
    <span te class="perpage-label">Sort by</span>
    <select name="orderby" class="orderby filterSelect" aria-label="Shop order" data-class="select-filter-orderby">
        <option for="alpha">Ordre Alphabetique</option>
        <option for="desc">Prix Decroissant</option>
        <option for="asc">Prix Croissant</option>
    </select>
</form>

>Solution :

Your syntax for <option> is wrong. for is an attribute used in <label> tags. The attribute to set an option’s value is value.

You do not need the hidden inputs either.

<form action="{{ action('App\Http\Controllers\HomePageController@processForm') }}" method="POST" class="woocommerce-ordering product-filter">
    @csrf
    <span class="orderby-label hide-desktop">Sort by</span>
    <span class="perpage-label">Sort by</span>
    <select name="sortoption" class="orderby filterSelect" aria-label="Shop order" data-class="select-filter-orderby">
        <option value="alpha">Ordre Alphabetique</option>
        <option value="desc">Prix Decroissant</option>
        <option value="asc">Prix Croissant</option>
    </select>
</form>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading