从下拉 Laravel 中获取所选值时始终获取 NULL

我试图通过我的控制器从我视图中的下拉列表中获取选定的值,但它总是返回null. 我真的不知道为什么。


这是我的选择下拉列表: 更新:这是我的完整刀片视图!


@extends('backpack::layout')


@section('header')

    <section class="content-header">

        <h1>

            <span class="text-capitalize">Thành tích tốt nhất ngày</span>

        </h1>

        <ol class="breadcrumb">

            <li><a href="/admin/dashboard">Admin</a></li>

            <li><a href="/admin/cache-club-earth">Thành tích tốt nhất ngày</a></li>

            <li class="active">List</li>

        </ol>

    </section>

@endsection


@section('content')

    <form method="GET">

        Lọc round:

            <select id="tablefilter" name="tablefilter">

            <option value="0">Hiện tại</option>

    

            @foreach($max as $item)

                <option value="{{$item->countRound}}">{{$item->countRound}}</option>

            @endforeach

    

        </select>

    </form>

    


    <table id="currentRound" class="table table-striped table-bordered" style="width:100%">

        <thead>

            <tr>

                <th>Câu lạc bộ</th>

                <th>Quãng đường</th>

                <th>Quãng đường trung bình</th>

                <th>Xếp hạng</th>

                <th>Số thành viên</th>

                <th>Ngày xếp hạng</th>

            </tr>

        </thead>

        <tbody>

        @foreach ($result as $item)

            <tr>

                <td>{{$item->name}}</td>

                <td align="right">{{number_format($item->total_distance/1000, 2)}} km</td>

                <td align="right">{{number_format($item->avg_distance/1000, 2)}} km</td>

                <td align="right">{{number_format($item->rank)}}</td>

                <td align="right">{{$item->total_member}}</td>

                <td>{{$item->created_at}}</td>

            </tr>

        @endforeach

        </tbody>

    </table>


冉冉说
浏览 162回答 3
3回答

幕布斯6054654

您需要使用按钮提交表单值或使用ajax发送表单值这里是通过表单提交的基本数据(我指定了如果您转到不同页面的操作)&nbsp; &nbsp; <form method="GET" action="{{url('/to/index/controller/you-want')}}>&nbsp; &nbsp; &nbsp; &nbsp; Lọc round:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <select id="tablefilter" name="tablefilter">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <option value="0">Hiện tại</option>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @foreach($max as $item)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<option value="{{$item->countRound}}">{{$item->countRound}}</option>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @endforeach&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </select>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <button class="something">Update</button>&nbsp; &nbsp; </form>

回首忆惘然

你可以这样做: dd(request->all());&nbsp;用于检查数据。我认为您不必使用输入功能。尝试这个 :$round&nbsp;=&nbsp;$request->tablefilter;

慕丝7291255

&nbsp;@foreach($max as $item)&nbsp; &nbsp; &nbsp;<option value="{{$item}}">{{$item}}</option>&nbsp;@endforeach
打开App,查看更多内容
随时随地看视频慕课网APP