drnzpd579935 2019-07-14 12:07
浏览 71

如何获取选定的数据值到路线?

Hello everyone I'm new to Stack overflow and posting for first time. I' m making an attendance management system for School. In my registration and attendance table I have

Registration : class_id, section_id, user_id.

Attendance :  date, user_id, remarks.

I want the user to select the Class then Section and Date and then it shows the all Users of that class and Section through registration table.

I'm having problem in taking that selected data to the route. I have tried this I want the data from dropdowns to in this form

<a href="{{url('/registration/data/'.$classs->class_id .$classs->section_id)}}">

PHP PAGE

@php use Illuminate\Support\Facades\DB;
$classs = DB::table("classses")->pluck("title","id");
$registrations= DB::table("registrations")->pluck("class_id","section_id");


@endphp



        <div class="form-group row">

            <label for="title" class="col-md-4 col-form-label">Select Class:*</label>

            <div class="col-md-4 col-form-label">
                <select name="class_id" class="form-control" style="width:360px" id="class_id" required autofocus>
                    <option value="">--- Select Class ---</option>
                    @foreach ($classs as $key => $value)
                        <option  value="{{ $key}}">{{ $value }}</option>
                    @endforeach
                </select>

            </div>
        </div>
        <div class="form-group row">
            <label for="title" class="col-md-4 col-form-label">Select Section:*</label>
            <div class="col-md-4 col-form-label">
                <select name="section_id" class="form-control" style="width:360px" required autofocus>
                    <option value="">--- Select Section --- </option >
                </select>
            </div>

        </div>



        <a href="{{url('/registration/data/'.$classs->class_id .$classs->section_id)}}">

            <div class="form-group " align="right">

            <button type="submit" class="btn btn-primary">

                {{ __('Submit') }}
            </button>

        </div>
        </a>

        <script type="text/javascript">
            $(document).ready(function() {
                $('select[name="class_id"]').on('change', function() {
                    var classID = $(this).val();
                    if(classID) {
                        $.ajax({
                            url: '/myform/ajax/'+classID,
                            type: "GET",
                            dataType: "json",
                            success:function(data) {


                                $('select[name="section_id"]').empty();
                                $.each(data, function(key, value) {
                                    $('select[name="section_id"]').append('<option value="'+ key +'">'+ value +'</option>');
                                });

                            }
                        });
                    }else{
                        $('select[name="section_id"]').append('<option >No Section Found</option>');
                    }
                });
            });
        </script>


    </div>
</div>
</div>

Mainly having issues to get id of selected data from drop downs trying this:

   <a href="{{url('/registration/data/'.$classs->class_id .$classs->section_id)}}">

            <div class="form-group " align="right">

            <button type="submit" class="btn btn-primary">

                {{ __('Submit') }}
            </button>

        </div>
        </a>

want to transfer id in this form in routes

 Route::any('/registration/data/{class_id}/{section_id}','AttendanceController@getUsers');
  • 写回答

2条回答 默认 最新

  • douping3427 2019-07-14 12:43
    关注

    I think you are just missing a slash in your url:

    <a href="{{url('/registration/data/'.$classs->class_id .$classs->section_id)}}">
    

    Should be:

    <a href="{{url('/registration/data/'.$classs->class_id .'/' .$classs->section_id)}}">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看