为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
冉冉说 2021-10-22 15:01:00
我试图通过我的控制器从我视图中的下拉列表中获取选定的值,但它总是返回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>
查看完整描述

3 回答

?
幕布斯6054654

TA贡献1876条经验 获得超7个赞

您需要使用按钮提交表单值或使用ajax发送表单值


这里是通过表单提交的基本数据(我指定了如果您转到不同页面的操作)


    <form method="GET" action="{{url('/to/index/controller/you-want')}}>

        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>

            <button class="something">Update</button>


    </form>


查看完整回答
反对 回复 2021-10-22
?
回首忆惘然

TA贡献1847条经验 获得超11个赞

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

$round = $request->tablefilter;


查看完整回答
反对 回复 2021-10-22
?
慕丝7291255

TA贡献1859条经验 获得超6个赞

 @foreach($max as $item)

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

 @endforeach


查看完整回答
反对 回复 2021-10-22
  • 3 回答
  • 0 关注
  • 161 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信