vendredi 24 juin 2016

Passing multiple id's from checkboxes to my controller in Laravel

in my view page i have a list of checkbox item in a table format. I want to send id of the selected checkbox(could be multiple id) when user click the add button to my controller. In the controller i will fetch some value and will pass it on to another view. below is my code

<div id="content">
    <div class="container">
        <div class="row">
            <div class="col-md-8">
                <div class="contact_form_holder">
                    
                    <div class="col-md-4">
                        
                        <div id="error_datepicker" class="error">Please check again</div>
                    </div>
                    <div class="col-md-4">
                        
                        <div id="error_datepicker" class="error">Please check again</div>
                    </div>
                    <p id="btnsubmit">
                        <input type="submit" id="send" value="Search" class="btn btn-custom"/>
                    </p>
                    
                </div>
                <div class="col-md-12">
                    @if (isset($roomname))
                    <table class="table table-hover" data-toggle="table" id="table"
                           data-click-to-select="true">
                        <thead>
                        <tr>
                            <th data-field="state" data-checkbox="true"></th>

                            <th data-field="roomname">Room Name</th>
                            <th data-field="Desc">Description</th>
                            <th data-field="price">Price</th>
                            <th data-field="roomid" data-visible="false">Price</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($roomname as $value)
                        <tr>
                            <td>{!! $value->roomid !!}</td>
                            <td>{!! $value->roomname !!}</td>
                            <td>{!! $value->Desc !!}</td>
                            <td>{!! $value->price !!}</td>
                            <td>{!! $value->roomid !!}</td>
                        </tr>
                        @endforeach
                        </tbody>
                    </table>
                    @endif
                </div>
                <div class="col-md-12">
                    <br>

                    <button id="add_cart" class="btn btn-warning">Proceed to booking</a></button>
                    <!-- on click of this button i want the clicked item id from the table and send it to the controller and from the controller it shoud redirect the value to another page  -->
                </div>
            </div>

my javascript

$.ajax({
    url: '/roombooking',
    type: "get",
    data: {id: data},
    success: function (response) { // What to do if we succeed
        if (data == "success") {
        }
    },
    error: function (response) {
        alert('Error' + response);
    }
});




Aucun commentaire:

Enregistrer un commentaire