在laravel中将复选框值从一个刀片传递到另一个刀片

时间:2019-06-23 20:08:52

标签: php laravel laravel-5

我在class Signature { constructor() { this.color = "#000000"; this.sign = false; this.begin_sign = false; this.width_line = 5; this.canvas = document.getElementById('canvas'); this.offsetLeft = this.canvas.offsetLeft; this.offsetTop = this.canvas.offsetTop; this.context = canvas.getContext('2d'); this.context.lineJoin = 'round'; this.context.lineCap = 'round'; this.whenMouseDown(); this.whenMouseUp(); this.whenMouseMove(); this.createSignature(); this.clearCanvas(); this.resetCanvas(); } updateMousePosition(mX, mY) { let rect = this.canvas.getBoundingClientRect(); let scaleX = this.canvas.width / rect.width; let scaleY = this.canvas.height / rect.height; this.cursorX = (mX - rect.left) * scaleX; this.cursorY = (mY - rect.top) * scaleY; } 中有多个弹出窗口,其中每个弹出窗口都有许多复选框。我试图获取test.blade.php框的值并将其显示在名为checked的新view中。但是brief没有显示该值。

注意此行:

  

brief.blade.php

我是laravel / php的新手,对如何传递数据感到困惑。我不清楚。

我看到了这些1 2的答案,但没有帮助。

  

test.blade.php

<form method="POST" action="{{ url('test/showBrief') }}">
  

TestController.php

@extends('layouts.app')

@section('content')
        <!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
    <style>
        /* Remove the navbar's default margin-bottom and rounded borders */
        .navbar {
            margin-bottom: 0;
            border-radius: 0;
        }

        /* Set height of the grid so .sidenav can be 100% (adjust as needed) */
        .row.content {
            height: 450px
        }

        /* Set gray background color and 100% height */
        .sidenav {
            padding-top: 20px;
            background-color: #f1f1f1;
            height: 100%;
        }

        /* Set black background color, white text and some padding */
        footer {
            background-color: #555;
            color: white;
            padding: 15px;
        }

        /* On small screens, set height to 'auto' for sidenav and grid */
        @media screen and (max-width: 767px) {
            .sidenav {
                height: auto;
                padding: 15px;
            }

            .row.content {
                height: auto;
            }
        }
    </style>
</head>
<body>

<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Manage your Event</a>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar navbar-left">
                <li class="active"><a href="#">Opportunities</a></li>
                <li><a href="#">Profile</a></li>
                <li><a href="#">Preferences</a></li>
                <li><a href="#">Contact</a></li>
                {{--<li><a href="#">About Us</a></li>--}}
            </ul>
            {{--<ul class="nav navbar-nav navbar-right">
                <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
            </ul>--}}
        </div>
    </div>
</nav>

<div class="container-fluid text-center">
    <div class="row content">
        <div class="col-sm-2 sidenav">
            <p><a href="#">Information</a></p>
            <p><a href="#">Matching</a></p>
            <p><a href="#">Services</a></p>
            <p><a href="#">Reviews</a></p>
            <p><a href="#">Works</a></p>
            <p><a href="#">Awards</a></p>
            <p><a href="#">Images</a></p>
            <p><a href="#">Managers</a></p>
            <p><a href="#">Team</a></p>
            <p><a href="#">Badges</a></p>
            <p><a href="#">Billing</a></p>
            <p><a href="#">Notifications</a></p>
        </div>
        <div class="col-sm-8 text-left">
            <h1>Welcome</h1>
            <p>We will ask you the right questions so we can introduce you to the right agencies.</p>
            <hr>
            <!-- Trigger the modal with a button -->
            <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Make
                Portfolio
            </button>


        </div>
        <div class="col-sm-2 sidenav">
            <div class="well">
                <p>sth</p>
            </div>
            <div class="well">
                <p>sth</p>
            </div>
        </div>
    </div>
</div>


<div class="container">

    <form method="POST" action="{{ url('test/showBrief') }}">
    @csrf
    <!-- Modal -->
        <div class="modal fade" id="myModal" role="dialog" aria-labelledby="modal1" aria-hidden="true">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Your Request 1</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                    </div>


                    <div class="modal-body">

                        <p id="checkid"></p>
                        <p>What service do you need?.</p>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Wedding</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Birthday</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Office party</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">PR event</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Branding and Positioning</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Anniversary celebration</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Office party</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="service" value="">Bridal Shower</label>
                        </div>

                    </div>


                    <div class="modal-footer">
                        <!--  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                        <button type="button" class="btn btn-default" id="btn1" data-toggle="modal"
                                data-target="#myModal">Previous
                        </button>
                        <button type="submit" class="btn btn-default" id="btn2"
                                data-toggle="modal" data-dismiss="modal"
                                data-target="#myModal2">Next
                        </button>

                    </div>


                    <?php include 'E:\xampp\htdocs\EventManagement\app\Http\Controllers\php_checkbox.php';?>
                </div>

            </div>


        </div>


        <!-- Modal 2 -->
        <div class="modal fade" id="myModal2" role="dialog">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Your Request 2</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>

                    </div>
                    <div class="modal-body">
                        <p>What budget range would you be comfortable with?.</p>
                        <div class="checkbox">
                            <label><input type="checkbox" name="range" value="">Tk. 1000-5000</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="range" value="">Tk. 5000-10000</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="range" value="">Tk. 10000-20000</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="range" value="">Tk. 20000-50000</label>
                        </div>

                        <div class="checkbox">
                            <label><input type="checkbox" name="range" value="">Tk. 1-2 Lakh</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" name="range" value="">Tk. 2-5 lakh</label>
                        </div>


                    </div>
                    <div class="modal-footer">
                        <!--  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                        <button type="button" class="btn btn-default" id="btn3" data-toggle="modal"
                                data-target="#myModal2">
                            Previous
                        </button>
                        <button type="button" class="btn btn-default" id="btn4" data-toggle="modal" data-dismiss="modal"
                                data-target="#myModal3">Next
                        </button>

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

        <!-- Modal 3 -->
        <div class="modal fade" id="myModal3" role="dialog">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Your Request 3</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>

                    </div>
                    <div class="modal-body">
                        <p>Where should the agency be located?.</p>
                        {{--<div class="checkbox">
                            <label><input type="checkbox" value="">Dhaka</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">Barishal</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">Chittagong</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">Khulna</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">Rajshahi</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">Sylhet</label>
                        </div>--}}


                    </div>
                    <div class="modal-footer">
                        <!--  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                        <button type="button" class="btn btn-default" id="btn5" data-toggle="modal"
                                data-target="#myModal3">
                            Previous
                        </button>
                        <button type="button" class="btn btn-default" id="btn6" data-toggle="modal" data-dismiss="modal"
                                data-target="#myModal4">Next
                        </button>

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

        <!-- Modal 4 -->
        <div class="modal fade" id="myModal4" role="dialog">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Your Request 4</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>

                    </div>
                    <div class="modal-body">
                        <p>Which language should the agency speak?.</p>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">Bangla</label>
                        </div>
                        <div class="checkbox">
                            <label><input type="checkbox" value="">English</label>
                        </div>
                    </div>


                    <div class="modal-footer">


                        <button type="button" onclick="window.location='{{ route("brief") }}'">Close
                        </button>

                        {{-- <a>
                             <button type="button" class="btn btn-default" id="close_btn" data-dismiss="modal"
                                     href="{{ url('/profile') }}"> {{ __('close') }}
                             </button>
                         </a>--}}
                        {{--<button type="button" onclick="window.location='{{ route("clientreg") }}'">Close</button>--}}
                        {{-- <button type="button" class="btn btn-default" id="close_btn" data-toggle="modal" data-dismiss="modal"
                                 data-target="#myDash">Close
                         </button>--}}


                        {{-- <a href="E:\xampp\htdocs\EventManagement\resources\views\home.blade.php" class="btn btn-info" id="close_btn"
                            role="button">Close</a>--}}

                        {{--  <button type="button" class="btn btn-aramark-primary"
                                  onclick="window.open('E:\\xampp\\htdocs\\EventManagement\\resources\\views\\home.blade.php')">
                         Go
                         </button>--}}
                    </div>

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


    </form>
    <footer class="container-fluid text-center">
        <p>About Us</p>
    </footer>

</div>

</body>
</html>
@endsection
  

brief.blade.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TestController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */

    protected $redirectTo = '/profile';


   /* public function __construct($data)
    {
        $this->data = $data;
    }*/
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('test');
    }

    public function index2()
    {
        return view('profile');
    }

    public function showBrief(Request $request)
    {

        $data = array(
            'service' => $request->service,
            'range' => $request->range
        );
        return view('brief');
       // return view('brief')->with('data', $this->data['service']);
    }
}
  

BriefController.php

<p>Service {{ $data['service'] }}</p>
<p>Range {{ $data['range'] }}.</p>
  

web.php

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;

class BriefController extends Controller
{
    public $data;
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        //return view('brief');
    }
    public function build()
    {
        //$this->brief = Input::get('service');
        return view('brief')->with('data', $this->data['service']);
    }
}

2 个答案:

答案 0 :(得分:0)

例如,您可以发送数据

return view('brief', ['data' => $data]);

或可以使用紧凑方法(如果名称相同)

return view('brief', compact('data');

然后在刀片中可以像这样使用

{{$data['service']}}

答案 1 :(得分:0)

我做错了MATCH (u:USER {name: "John"}) MATCH (a:AGE {name: "28"}) CREATE (u)-[:IS]->(a) 方法。

post

这里应该是

  

<button type="button" onclick="window.location='{{ route("brief") }}'">Close </button>

button type="submit"中,它将是web.php方法,而不是post

  

get