Laravel表格提交确认框

时间:2018-11-30 07:52:55

标签: laravel forms

我是Laravel的初学者,想知道在进入/delete/{id}?之前是否有任何方法可以确认删除

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row justify-content-center">
    <div class="col-md-8 col-md-offset-2">
        <div class="panel panel-default">

            <div class="panel-heading"><h2>List of Records:</h2></div>

        </div>


        <div class="card">
            <div class="card-header">Dashboard</div>

            <div class="card-body">
                @if (session('status'))
                    <div class="alert alert-success" role="alert">
                        {{ session('status') }}
                    </div>
                @endif

                    <p class="bg-primary">Record ID  {{$record->id}}</p>
                    <p class="bg-success">Respond ID  {{$record->col1}}</p>
                    <p class="bg-info">Start Date  {{$record->col2}}</p>
                    <p class="bg-warning">End Date   {{$record->col3}}</p>
                    <p class="bg-danger">Better Consumer Tools  {{$record->col4}}</p>
                    <p class="bg-primary">More public education  {{$record->col5}}</p>
                    <p class="bg-success">Strengthen energy efficiency  {{$record->col6}}</p>
                    <p class="bg-info">Phase out inefficient stuff  {{$record->col7}}</p>
                    <p class="bg-warning">Demand program   {{$record->col8}}</p>
                    <p class="bg-danger">Lower business needs  {{$record->col9}}</p>
                    <p class="bg-primary">Stronger standards {{$record->col10}}</p>
                    <p class="bg-success">Created at  {{$record->created_at->format('d/m/y H:i')}}</p>
                    <p class="bg-info"><a href="editrec/{{$record->id}}">Edit</a>|<a href="deleteRec/{{$record->id}}">Delete</a><p>
                    <a href="/home"><button type="button">Go back to Main</button></a>

                </div>
            </div>
        </div>
    </div>
</div>
@endsection

如果我使用JavaScript函数,该函数如何处理定位标记以进行href路由?

1 个答案:

答案 0 :(得分:1)

在您的定位标记中使用此

<a onclick="return confirm('Are you sure?')" href="deleteRec/{{$record->id}}">Delete</a>