Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取输入值并将其传递到同一刀片文件Laravel 5.7中的route_Laravel - Fatal编程技术网

获取输入值并将其传递到同一刀片文件Laravel 5.7中的route

获取输入值并将其传递到同一刀片文件Laravel 5.7中的route,laravel,Laravel,我想将下拉列表中的选定值传递给同一刀片文件中的抛出路由 这是我的刀片代码: <div class="form-group col-md-2"> <label>@lang('site.son')</label> @if(Auth::user()->shortsign == '--') <select class="select2-size-lg form-control border-primary" style="widt

我想将下拉列表中的选定值传递给同一刀片文件中的抛出路由

这是我的刀片代码:

<div class="form-group col-md-2">
    <label>@lang('site.son')</label>

    @if(Auth::user()->shortsign == '--')
    <select class="select2-size-lg form-control border-primary" style="width: 100%;" name="sign">
        @foreach ($users as $user)
        <option value="{{ $user->shortsign }}">{{ $user->shortsign }}</option>
        @endforeach
    </select>
    @else
    <select class="select2-size-lg form-control border-primary" style="width: 100%;" name="sign" readonly>
        <option value="{{ Auth::user()->shortsign }}">{{ Auth::user()->shortsign }}</option>
    </select>
    @endif

</div>

<div class="form-actions right">
    <a href="{{  url('/salereports/report/' . $user->shortsign) }}" class="btn btn-outline-dark btn-min-width box-shadow-2 mr-1 mb-1"><i class="la la-search" aria-hidden="true"></i> @lang('site.search')</a>
</div>

@lang('site.son')
@如果(Auth::user()->shortsign=='--')
@foreach($users作为$user)
{{$user->shortsign}
@endforeach
@否则
{{Auth::user()->shortsign}
@恩迪夫

现在,代码iam使用“从数据库中传递最后一个值未选定值”

您可以通过向锚定标记提供id来尝试此操作

<script type="text/javascript">
   $('.select2-size-lg').change(function () {
    var id = $(this).val(); 
    document.getElementById("abc").href="{{  url('/salereports/report/' . id) }}";
});
</script>

$('.select2 size lg')。更改(函数(){
var id=$(this.val();
document.getElementById(“abc”).href=“{{url('/salereports/report/'.id)}”;
});

由于您在
@foreach($users as$user)
循环之后使用了
$user->shortsign
,因此该值等于上次迭代后的
$user
值。除此之外,您还需要一些Javascript来将值设置到
href
中。我得到了错误ErrorException(E_error)使用未定义的常量id-假定的'id'(这将在PHP的未来版本中引发错误)(视图:C:\xampp\htdocs\orbiggit\resources\views\salereports\index.blade.PHP)以前的异常使用未定义的常量id-假定为“id”(这将在未来版本的PHP中引发错误)(0)尝试在id之前添加+符号,而不是DOT。我认为您应该像此文档一样。getElementById(“abc”).href=“”/salereports/report/'.id”