PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 21, 2022

[FIXED] dropdwon send always last value in filter

 February 21, 2022     filtering, laravel, laravel-blade, php     No comments   

Issue

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

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>


Answered By - IGP
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing